Azzera filtri
Azzera filtri

opening a cdf file

5 visualizzazioni (ultimi 30 giorni)
Sonali
Sonali il 16 Apr 2024
Commentato: Sonali il 17 Apr 2024
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 Commenti
the cyclist
the cyclist il 16 Apr 2024
CDF can mean a few different things. For example, is it Common Data Format, or Computable Document Format, or something else?
Sonali
Sonali il 17 Apr 2024
common data format, here.

Accedi per commentare.

Risposta accettata

Gyan Vaibhav
Gyan Vaibhav il 17 Apr 2024
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

Più risposte (0)

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by