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
  1 件のコメント
Sonali
Sonali 2024 年 4 月 17 日
Thanks Gyan. It worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by