How to read .bnn.lis file (ascii file) for the specific data
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
SHUBHAM AGARWAL
am 26 Aug. 2022
Kommentiert: Mathieu NOE
am 26 Aug. 2022
Dear Experts,
I want to read the values inside orange line as an array.
file name is " SCINTILLAORS STACK WITH CHAMBER-1_21.bnn.lis " which looks like in the image (file is attached which I can open in with .txt format as i couldn't attach the original .bnn.lis file).
I tried the following method but it is not giving the desired terms
filename='SCINTILLAORS STACK WITH CHAMBER-1_21.bnn.lis';
fileid=fopen(filename);
c=textscan(fileid,'%f %f %f %f %f %f %f %f %f %f %f %f %f %f %f');
fclose(fileid);
whos c
Please, help me take out the values inside the orange line
Thank you
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 26 Aug. 2022
hello
this is one possibility :
lines = readlines('SCINTILLAORS STACK WITH CHAMBER-1_21.txt');
%% main code
nn = find(contains(lines,'accurate deposition along the tracks requested')); % find the line number of this text
lines_to_read = 2; % read the 2 lines after line containing above text
for ck = 1:lines_to_read
tmp = (str2double(split(lines(nn+ck))))';
tmp(isnan(tmp)) = []; % remove NaNs
out{ck,1} = tmp; % store in cell array
end
% export to txt
writecell(out,'output.txt',"Delimiter","\t");
5 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Text Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!