Textscan Reads Only the first 3 numbers

2 visualizaciones (últimos 30 días)
Fabio Taccaliti
Fabio Taccaliti el 26 de Sept. de 2022
Comentada: Geoff Hayes el 26 de Sept. de 2022
Hello,
I´m trying to read this .txt (attached) file and store the values (54 columuns).
This is the code that I´m using
Name_1 = 'fffff.txt';
fid = fopen(Name_1,'r');
cell_data1= textscan(fid,'%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','Delimiter','','headerLines',6,'CollectOutput',1);
fclose(fid);
But unfortunately the code is messing with the first two columns (data and time).
This is what it stores.
How can I skip those two and just store the remaining 52 columns?
Thanks in advance
  2 comentarios
Fabio Taccaliti
Fabio Taccaliti el 26 de Sept. de 2022
This is how it looks like :)

Iniciar sesión para comentar.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 26 de Sept. de 2022
@Fabio Taccaliti - perhaps instead you can use readtable to read the table from file and then extract the data you need. For example,
filename = 'fffff.txt';
tableData = readtable(Name_1,'Delimiter','\t','headerLines',6);
data = tableData(:,3:end);
  4 comentarios
Geoff Hayes
Geoff Hayes el 26 de Sept. de 2022
There must be some invalid data in one of your date or time columns. You may need to glance through the data to figure out which field is invalid. Or exclude those columns altogether (which I thought is what you wanted to do?).

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by