could not open my nc file, error using ncread and loop
이전 댓글 표시
this is my code:
files = dir('/media/wrfout_d02_2015-02*');
for i=1:length(files);
filename = files(i).name;
data_ori = double(ncread(filename,'PM10'));
and I got this error;
Error using internal.matlab.imagesci.nc/openToRead (line 1259)
Could not open wrfout_d02_2015-02-01_00:00:00 for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 53)
ncObj = internal.matlab.imagesci.nc(ncFile);
can anyone help me? what is the error mean? thank you
답변 (1개)
Walter Roberson
2018년 1월 16일
편집: Walter Roberson
2018년 1월 16일
projectdir = '/media';
files = dir( fullfile(projectdir, 'wrfout_d02_2015-02*') );
for i = 1:length(files);
filename = fullfile(projectdir, files(i).name );
data_ori = double(ncread(filename,'PM10'));
end
댓글 수: 5
nsyn
2018년 1월 16일
nsyn
2018년 1월 16일
Walter Roberson
2018년 1월 16일
Did you truly put the files directly in /media ? That would be rather unusual: /media is almost always used to mount filesystems so there would be a mount-point directory name under /media and files would be underneath that.
nsyn
2018년 1월 16일
Walter Roberson
2018년 1월 17일
If you are using R2016b or later (or is it R2017a or later?) you can use
files = dir('/media/Seagate1/myaccount/2015output/wrfout_d02_2015-02*');
for i=1:length(files);
filename = fullfile(files(i).folder, files(i).name);
data_ori = double(ncread(filename,'PM10'));
end
카테고리
도움말 센터 및 File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!