Borrar filtros
Borrar filtros

opening a cdf file

23 visualizaciones (últimos 30 días)
Sonali
Sonali el 16 de Abr. de 2024 a las 20:03
Comentada: Sonali el 17 de Abr. de 2024 a las 14:24
Hello, I am trying to open a cdf file. I have a program which has opened some cdf files in past. But Im unable to open the new set.
prog:
files='D:\CDF\';
files = dir('mvn_*.cdf');
num_files = length(files);
data= cell(1, num_files);
nam=files.name;
for j = 1:numel(files)
list = fullfile(files(j).folder, files(j).name);
vars = cdfinfo(list).Variables(:,1);
data{j} = cell2table(cdfread(list), 'VariableNames', vars);
end
Will really appreciate a solution here. Thanks
  2 comentarios
the cyclist
the cyclist el 16 de Abr. de 2024 a las 21:09
CDF can mean a few different things. For example, is it Common Data Format, or Computable Document Format, or something else?
Sonali
Sonali el 17 de Abr. de 2024 a las 13:26
common data format, here.

Iniciar sesión para comentar.

Respuesta aceptada

Gyan Vaibhav
Gyan Vaibhav el 17 de Abr. de 2024 a las 9:56
Hi Sonali,
I understand from the code you have provided, that you want to read a Common Data Format (CDF) file. I tried running your program and everything seems alright, however the cdfread function throws an error.
As of R2021a, reading CDF files which use a few certain datatypes is not supported. However, you can use the spdfcdfread function present in the patch provided by NASA for reading the CDF files you have. This could be the possible reason, which has been mentioned here for a similar problem. https://www.mathworks.com/matlabcentral/answers/765971-how-to-access-cdf-file
Download the patch file, and extract it to a specified folder. Add that folder to matlab path using the addpath command. You can get the patch and detailed installation instructions from here: https://cdf.gsfc.nasa.gov/html/matlab_cdf_patch.html
Once you are done with that change "cdfread" in your function to "spdfcdfread" as shown below and it generates the expected "data" table.
data{j} = cell2table(spdfcdfread(list), 'VariableNames', vars);
Hope this resolves your query.
Thanks
Gyan
  1 comentario
Sonali
Sonali el 17 de Abr. de 2024 a las 14:24
Thanks Gyan. It worked.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Import and Analysis 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