opening a cdf file

16 次查看(过去 30 天)
Sonali
Sonali 2024-4-16
评论: Sonali 2024-4-17
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 个评论
the cyclist
the cyclist 2024-4-16
CDF can mean a few different things. For example, is it Common Data Format, or Computable Document Format, or something else?
Sonali
Sonali 2024-4-17
common data format, here.

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by