Textscan Reads Only the first 3 numbers

3 vues (au cours des 30 derniers jours)
Fabio Taccaliti
Fabio Taccaliti le 26 Sep 2022
Commenté : Geoff Hayes le 26 Sep 2022
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);
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 commentaires
Fabio Taccaliti
Fabio Taccaliti le 26 Sep 2022
This is how it looks like :)

Connectez-vous pour commenter.

Réponse acceptée

Geoff Hayes
Geoff Hayes le 26 Sep 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 commentaires
Geoff Hayes
Geoff Hayes le 26 Sep 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?).

Connectez-vous pour commenter.

Plus de réponses (0)


Community Treasure Hunt

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

Start Hunting!

Translated by