This is my function:
function download(d)
[date_string] = datestr(d, 'yyyy-mm-dd')
yyyy = date_string(1:4);
mm = date_string(6:7);
dd = date_string(9:10);
download_string = ['password and username and the link' yyyy mm dd '.nc4'];
disp('Executing this string: ');
disp(download_string);
ncdisp(['MERRA2_400.inst6_3d_ana_Np.' yyyy mm dd '.nc4 '])
system(download_string);
I get this error, why??
Error using internal.matlab.imagesci.nc/openToRead (line 1259)
Could not open MERRA2_400.inst6_3d_ana_Np.20161001.nc4 for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncdisp (line 50)
ncObj = internal.matlab.imagesci.nc(ncFile);
Someone know what to do?

2 件のコメント

Jan
Jan 2017 年 5 月 22 日
編集済み: Jan 2017 年 5 月 22 日
The posted code does not run: A [ is missing. Please post the code, which is failing, not some similar code.
kk1991
kk1991 2017 年 5 月 22 日
Thanks and sorry. My mistake! However, this is my code. I just have hidden my password and username.

サインインしてコメントする。

 採用された回答

Jan
Jan 2017 年 5 月 22 日

0 投票

The error message seems to be clear:
Could not open MERRA2_400.inst6_3d_ana_Np.20161001.nc4 for reading.
There is an empty space at the end of the name, perhaps this matters. Unfortunately this space seems to be inserted exactly in this line, which has an inproper syntax:
ncdisp('MERRA2_400.inst6_3d_ana_Np.' yyyy mm dd '.nc4 '])
Therefore I cannot guess, if the original code contains the same problem.
We cannot know, if this object is existing, but you can and should check this. Please provide the detail, if this file is missing (if it is a file at all, I do not know the command ncdisp.

3 件のコメント

kk1991
kk1991 2017 年 5 月 22 日
If I remove the ncdisp, the file is downloading perfectly. And if I use the ncdisp or ncread in a separate script matlab read the file perfectly. The problem occurs when i put this two scripts together. I tried without the space at the end, but it didn't work, I got the same error.
Jan
Jan 2017 年 5 月 22 日
Perhaps the file is not in the current folder?
file = fullfile(cd, ['MERRA2_400.inst6_3d_ana_Np.' yyyy mm dd '.nc4']);
if ~exist(file, 'file')
error('File not found: %s', file);
end
ncdisp(file);
Is the file really existing? It will be much better not to use cd, but the real folder name.
kk1991
kk1991 2017 年 5 月 24 日
It worked!! Thank you so much for your help! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import and Analysis についてさらに検索

タグ

質問済み:

2017 年 5 月 22 日

コメント済み:

2017 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by