How to open .lmf file

조회 수: 56 (최근 30일)
mohd akmal masud
mohd akmal masud 2024년 11월 22일 15:56
답변: Harsh Sharma 2024년 11월 24일 18:46
Dear All,
I have the pointclass3.lmf file as attached. But I dont know how to open it. In manual just said like below:
"This routine saves information about the photon history in a binary list mode file. The file will have the extension *.lmf. To save disk space, each record of a history in the binary file will have nine 16-bit integer values, one 64-bit float value, and one 8-bit value in the order indicated in the table. "
Anyone can hel me?
  댓글 수: 8
mohd akmal masud
mohd akmal masud 2024년 11월 23일 9:14
Dear @DGM
I was try your syntax. All is well.
But the value in workspace I dont know what is it actually?
Is it is images? is it is data? is it is graph profile?
Can you help me how to view all that valu workspace?
mohd akmal masud
mohd akmal masud 2024년 11월 23일 9:26
Dear @DGM,
headerlen = mod(numel(stream),recordlen) % is there a header??
The header files is attached.

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

답변 (1개)

Harsh Sharma
Harsh Sharma 2024년 11월 24일 18:46
Hi Akmal,
You can use “fread” function to read a binary file in MATLAB. Below is the code to read data in the format mentioned by you.
% Open the file in binary read mode
fileID = fopen('pointclass3.lmf', 'rb');
numRecords = 10; % As an example we read 10 records
% Preallocate arrays to store data
int16Data = zeros(numRecords, 9, 'int16'); % 9 int16 values per record
float64Data = zeros(numRecords, 1, 'double'); % 1 float64 value per record
int8Data = zeros(numRecords, 1, 'int8'); % 1 int8 value per record
% Loop to read each record
for i = 1:numRecords
int16Data(i, :) = fread(fileID, 9, 'int16'); % Read 9 int16 values
float64Data(i) = fread(fileID, 1, 'double'); % Read 1 float64 value
int8Data(i) = fread(fileID, 1, 'int8'); % Read 1 int8 value
end
% Close the file
fclose(fileID);
% Display the first record as an example
disp('First Record:');
disp('Int16 Data:');
disp(int16Data(1, :));
disp('Float64 Data:');
disp(float64Data(1));
disp('Int8 Data:');
disp(int8Data(1));
Here’s the output for the above code-
You may refer to the following documentation to learn more about “fread” function - https://www.mathworks.com/help/matlab/ref/fread.html

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by