Read txt file with no header
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Iacopo
el 22 de Abr. de 2022
Editada: Les Beckham
el 22 de Abr. de 2022
Hi all, I have attached one of the txt I need to extract only the numeric data from, skipping thr headers. it works for that file but I want to extens the code to files with a different (unknown) number of columns. Can anyone help me to modify it?
The piece of code I used is:
fid=fopen('text.txt');
data=textscan(fid,'%f %f %f %f %f %f %f %f %f %f','HeaderLines','4');
data=cell2mat(data);
fclose(fid);
Thanks
0 comentarios
Respuesta aceptada
Les Beckham
el 22 de Abr. de 2022
Editada: Les Beckham
el 22 de Abr. de 2022
This should work for any number of columns and it automatically detects the number of header rows and the variable names.
t = readtable('text.txt')
data = table2array(t); % convert to a plain numeric array
whos data
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps 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!