Saving multiple ASCII files from NetCDF
조회 수: 2 (최근 30일)
이전 댓글 표시
I have an 145x157x1470 NetCDF file with this dimensions, and I need to save one ASCII file for each lat-lon. I could get to this code:
%Loading .nc
File = 'siprec_2009-2012.nc.nc';
ncdisp(File);
siprec = ncread(File,'SIPREC');
time = ncread(File,'time');
lat = ncread(File,'latitude');
lon = ncread(File,'longitude');
%
%loop for create ascii files
varInfo = ncinfo(File,'SIPREC');
disp(varInfo);
for latInd =1:varInfo.Size(1)
for lonInd =1:varInfo.Size(2)
fileName = ['siprec_',num2str(lat),'_',num2str(lonInd),'.srm'];
tSeries = [ncread('siprec_2009-2012.nc','SIPREC',[latInd, lonInd, 1],[1,1,varInfo.Size(3)])];
SerieFinal= [time squeeze(tSeries)];
dlmwrite(fileName,SerieFinal,'delimiter','\t','precision',5);
end
end
But, since this return more than 22k files, I need the value of lat and lon in each file name, but this code only save with the index of lat and long.
i.e. instead of 'siprec_25.35_49.27.srm', the file is saved as 'siprec_1_92.srm'.
What can I change to save the files with lat and lon values?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NetCDF에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!