why am i getting this error ? what to do?

4 visualizaciones (últimos 30 días)
OMKAR ACHARJEE
OMKAR ACHARJEE el 21 de Jun. de 2018
Editada: JAYANTH BHIMAVARAPU el 21 de Jun. de 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);

Respuesta aceptada

JAYANTH BHIMAVARAPU
JAYANTH BHIMAVARAPU el 21 de Jun. de 2018
Editada: JAYANTH BHIMAVARAPU el 21 de Jun. de 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 comentarios
Stephen23
Stephen23 el 21 de Jun. de 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
JAYANTH BHIMAVARAPU el 21 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

Stephen23
Stephen23 el 21 de Jun. de 2018
Editada: Stephen23 el 21 de Jun. de 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

Categorías

Más información sobre Denoising and Compression en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by