MATLAB打开nc文件并读取nc文件数据 | 您所在的位置:网站首页 › matlab读取网页数据 › MATLAB打开nc文件并读取nc文件数据 |
MATLAB打开nc文件
ncdisp('E:\**\**.nc')
输入该命令后命令行窗口会显示该nc文件的基本信息 MATLAB读取nc文件根据上一步中nc文件的基本信息提取nc文件的相应数据。 time=ncread('E:\**\**.nc','time') 将nc文件中所需要的数据保存至txt文档首先,将所需要的数据提取出来 start=[125,89,123] count=[17,14,124] tmax=ncread('E:\**\**.nc','tmax',start,count)其中,start 表示开始读取数据的地方,本例即从第125行89列123页开始读取; count 表示要读取的个数,本例即为要读取17行14列124页; 本例默认步长为1,故未添加 stride。 最后,将数据保存至txt文档 fid=fopen('E:\**\***.txt','w')其中,‘w’ 表示打开***.txt文档并删除之前的数据重新写入,若没有该文档,即创建一个新文档并写入数据。 ‘a’ 表示在原有的数据基础上后续添加数据,保留原有数据。 其余表达见下,摘自MATLAB帮助文件。 ‘r’ : open file for reading ‘w’ : open file for writing; discard existing contents ‘a’ : open or create file for writing; append data to end of file ‘r+’ : open (do not create) file for reading and writing ‘w+’ : open or create file for reading and writing; discard existing contents ‘a+’: open or create file for reading and writing; append data to end of file ‘W’ : open file for writing without automatic flushing ‘A’ : open file for appending without automatic flushing fprintf(fid,'%g\n',tmax(1,1,k))其中,\n表示换行 |
CopyRight 2018-2019 实验室设备网 版权所有 |