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

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')
arr = 1×4 cell array
{'New folder (3)/desktop.ini'} {'New folder (3)/imshow3D.m'} {'New folder (3)/jaszaki1318n1date15012024…'} {'New folder (3)/jaszaki1318n1date15012024…'}
fname = 'jaszaki13110n1date14012024531193.cdf';
fid = fopen(fname)
fid = -1
cdfread(fname)
Error using cdfread
Unable to open file. File might be corrupt or filename might have unsupported characters.

댓글을 달려면 로그인하십시오.

 채택된 답변

Voss
Voss 2024년 1월 19일
이동: Voss 2024년 1월 19일

0 개 추천

sz = [128 128 128];
unzip('New folder (3).zip')
ls
'New folder (3)' 'New folder (3).zip'
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 = struct with fields:
name: 'jaszaki1318n1date15012024.cdf' folder: '/users/mss.system.nXJGBc/New folder (3)' date: '16-Jan-2024 03:34:26' bytes: 16777216 isdir: 0 datenum: 7.3927e+05
F(1).bytes/8 == prod(sz)
ans = logical
1
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

mohd akmal masud
mohd akmal masud 2024년 1월 20일
Dear @Voss
Thank you very much, this is what I need.
Voss
Voss 2024년 1월 20일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2024년 1월 19일

댓글:

2024년 1월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by