Textscan Reads Only the first 3 numbers

2 views (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 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 Comments
Geoff Hayes
Geoff Hayes on 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?).

Sign in to comment.

More Answers (0)

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by