Borrar filtros
Borrar filtros

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

9 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 26 de Ag. de 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 comentarios
SHUBHAM AGARWAL
SHUBHAM AGARWAL el 26 de Ag. de 2022
Dear Mathieu,
Thank you very much. You are a great help and teacher.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by