How to open .cdf file
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mohd akmal masud
el 19 de En. de 2024
Comentada: Voss
el 20 de En. de 2024
Hai Everyone,
Anyone can help me how to open the .cdf file as attacheed.
The .cdf file is their header file. Attached.
I tried this code but failed.
**I also attached the function imshow3D
clc
clear all
close all
sz = [128 128 128];
fname = 'jaszaki13110n1date14012024531193.cdf';
fid = fopen(fname);
data = fread(fid,'*uint16'); % assuming uint
fclose(fid);
% this is blindly devectorized
% may still be transposed, but i can't tell due to symmetry
% note that data is unit-scale single-precision float
data = reshape(data,sz);
imshow3D(data);
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that
dimension.
1 comentario
Dyuman Joshi
el 19 de En. de 2024
cdfread would be a better option here.
However, the file you have attached seems to be corrupt - as can be seen from the output of fopen() and the error from cdread()
arr = unzip('New folder (3).zip')
fname = 'jaszaki13110n1date14012024531193.cdf';
fid = fopen(fname)
cdfread(fname)
Respuesta aceptada
Voss
el 19 de En. de 2024
Movida: Voss
el 19 de En. de 2024
sz = [128 128 128];
unzip('New folder (3).zip')
ls
addpath('New folder (3)') % to run imshow3D.m
The size of the cdf file (16777216 bytes) is consistent with the file containing 128*128*128 64-bit elements.
F = dir(fullfile('New folder (3)','*.cdf'))
F(1).bytes/8 == prod(sz)
Whether those are uint64s or doubles, I don't know, but I'd guess doubles based on what imshow3D shows.
fid = fopen(fullfile(F(1).folder,F(1).name));
data = fread(fid,'*uint64');
fclose(fid);
data = reshape(data,sz);
figure
imshow3D(data);
fid = fopen(fullfile(F(1).folder,F(1).name));
data = fread(fid,'double');
fclose(fid);
data = reshape(data,sz);
figure
imshow3D(data);
Does that look like what's expected?
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!