Hey Guys,
I want to read and modify a txt.-file via MatLab and store the resulting data.
What I would like to do is to only keep the lines of the file which contain more than 100 characters and discard all the other lines/rows.
Thanks for the help!

4 comentarios

KSSV
KSSV el 14 de Sept. de 2020
How is text file? What data text file has?
trst111
trst111 el 14 de Sept. de 2020
The text file consists of 6 columns of data/text (columns are separated via spaces) and a huge amount of rows. I want to put everything into a matrix, except all the rows whose character count is less than 100.
KSSV
KSSV el 14 de Sept. de 2020
Each rows has six columns....so what is a single element? It is a string right?
Attach some part of your file here. Or copy paste few lines.
trst111
trst111 el 14 de Sept. de 2020
Its built like this:
Value1 Value2 Value3 Value4 Value5 Value6
Value7 Value8 Value9 Value10 Value11 Value12
Value13 Value14 Value15 Value16 Value17 Value18
...
the values are looking like this: -6.314264449E-002

Iniciar sesión para comentar.

 Respuesta aceptada

Rik
Rik el 14 de Sept. de 2020

0 votos

Trivial if you read your file to a cell array (e.g. with readfile, which you can get from the FEX or through the AddOn-manager (R2017a or later)).
L=false(numel(data));
for n=1:numel(data)
L(n)=numel(data{n})<100;
end
data(L)=[];

Más respuestas (0)

Preguntada:

el 14 de Sept. de 2020

Respondida:

Rik
el 14 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by