想把文件夹里的所有nc数据都转存为mat格式,下面有一个循环,但是保存之后只有一个mat文件,请大神帮忙看一下,非常感谢
pathname='F:\葵花小时\201507\07\';
files=dir([pathname,'*.nc']);
for i=1:length(files)
filename=[pathname,files(i).name];
SST=ncread(filename,'sea_surface_temperature');
% SST=SST(6961:7441,1152:1584);
% sst(:,:,i)=SST;
save('.mat','SST')
end

 Accepted Answer

0 votes

你前面不是也知道根据控制变量 i 的数值来读取不同文件名对应的文件么,存的时候也类似啊
save('.mat','SST')
这句改成类似
save( [ files(i).name, '.mat' ], 'SST' )
的写法

More Answers (0)

Categories

Find more on MATLAB 快速入门 in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!