How to read .bnn.lis file (ascii file) for the specific data

20 次查看(过去 30 天)
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

采纳的回答

Mathieu NOE
Mathieu NOE 2022-8-26
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 个评论

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by