how to plot graph as file attached.
이전 댓글 표시
Dear all,
I have file as attached. Anyone can help me how to plot the graph from the file as attached.
댓글 수: 2
Epsilon
2024년 12월 11일
Hi mohd, Can you please elaborate what kind of a plot are you looking for.
mohd akmal masud
2024년 12월 11일
답변 (1개)
Mathieu NOE
2024년 12월 11일
hello
you can read your header file with any matlab function that read ascii / txt files . Here I opted for readlines . Still you have to say what we want to do now with the header
then you can use your code to extract the data, you only need to apply the sacling factor correction to have your plot with the right data (in keV)
%% read header file
header = readlines('pointlmf.h00');
% and now ? ...
%% open lmf file
fid = fopen('pointclass3.lmf');
stream = fread(fid,inf,'*uint8');
fclose(fid);
recordlen = 20 + 8 + 1; % 10x16b, 1x64b, 1x8b
headerlen = mod(numel(stream),recordlen) % is there a header??
header = stream(1:headerlen);
data = reshape(stream(headerlen+1:end),recordlen,[]);
% the 16b fields
xyz0 = typecast(reshape(data(1:6,:),[],1),'uint16');
xyz0 = reshape(xyz0,3,[]).';
xyzphantom = typecast(reshape(data(7:12,:),[],1),'uint16');
xyzphantom = reshape(xyzphantom,3,[]).';
xyzcrystal = typecast(reshape(data(13:18,:),[],1),'uint16');
xyzcrystal = reshape(xyzcrystal,3,[]).';
energy = typecast(reshape(data(19:20,:),[],1),'uint16');
% the double float field
photonweight = typecast(reshape(data(21:28,:),[],1),'double');
% the 8b field
scatterorder = typecast(reshape(data(29,:),[],1),'uint8');
%% plot energy
energy = double(energy/10); % apply energy scaling factor = 10, then convert to double (optionnal) ; now units are keV
plot(energy);
ylabel('keV')
댓글 수: 1
Mathieu NOE
2025년 4월 2일
hello again
problem solved ?
카테고리
도움말 센터 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

