why am i getting this error ? what to do?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
OMKAR ACHARJEE
le 21 Juin 2018
Modifié(e) : JAYANTH BHIMAVARAPU
le 21 Juin 2018
dirpath=('C:\Users\AKASH\Pictures\works\**');
files=dir('C:\Users\AKASH\Pictures\works\**\3B*');
nfiles=length(files);
datadir = 'C:\Users\AKASH\Pictures\works\**';
fname = '3B42.19980101.00.7.SUB.nc';
lat1 = ncread([datadir,fname],'latitude');
lon1 = ncread([datadir,fname],'longitude');
Error using internal.matlab.imagesci.nc/openToRead (line 1259)
Could not open C:\Users\AKASH\Pictures\works\**3B42.19980101.00.7.SUB.nc for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 53)
ncObj = internal.matlab.imagesci.nc(ncFile);
0 commentaires
Réponse acceptée
JAYANTH BHIMAVARAPU
le 21 Juin 2018
Modifié(e) : JAYANTH BHIMAVARAPU
le 21 Juin 2018
Replace datadir = 'C:\Users\AKASH\Pictures\works\**'; with datadir = 'C:\Users\AKASH\Pictures\works\**\'; and try again. But don't forget to change * * with exact file location path.
2 commentaires
Stephen23
le 21 Juin 2018
@JAYANTH BHIMAVARAPU: how will that help if that directory still does not exist, and so concatenting it (with or without the file separator) will always produce an error?
JAYANTH BHIMAVARAPU
le 21 Juin 2018
Yeah I understood your point but I mean to say that if he gives the correct path to that .nc file with file separators, he can access that file for reading.
Plus de réponses (1)
Stephen23
le 21 Juin 2018
Modifié(e) : Stephen23
le 21 Juin 2018
Read the error message. Is datadir = 'C:\Users\AKASH\Pictures\works\**' a directory that exists on your computer? Is C:\Users\AKASH\Pictures\works\**3B42.19980101.00.7.SUB.nc the full name of a file on your computer? Neither that path nor that file exist on your computer. You can see these names clearly in the error message and your code, so it is easy to see why there is an error.
Also, use fullfile rather than string concatenation. If you don't need to use the recursive search, then you will need to do something like this:
D = 'C:\Users\AKASH\Pictures\works';
S = dir(fullfile(D,'3B*.nc'));
for k = 1:numel(S)
fnm = fullfile(D,S(k).name);
lat = ncread(fnm,'latitude');
lon = ncread(fnm,'longitude');
...
end
0 commentaires
Voir également
Catégories
En savoir plus sur Encryption / Cryptography dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!