textscan only reads first row of text file
12 views (last 30 days)
Show older comments
filename = 'Prova_1.txt';
fileID = fopen(filename,'r');
time = 'Time: %d ';
acceleration = 'G in body frame: %f ;%f ;%f ; ';
omega = 'Omega: %f ;%f ;%f ; ';
balane = 'r balane: %f ;%f ;%f ; ';
quaternion = 'quat: %f ;%f ;%f ; %f ; ';
magnetic = 'Mag: %f ;%f ;%f ; %f ;%f ;%f ;';
formatSpec = [time acceleration omega balane quaternion magnetic];
A = textscan(fileID,formatSpec);
fclose(fileID);
With the code included it only reads the first row of the text file. Can't find what's wrong or missing.
0 Comments
Accepted Answer
Stephen23
on 7 Nov 2021
Edited: Stephen23
on 7 Nov 2021
fmt = 'Time%dG in body frame%f%f%fOmega%f%f%fr balane%f%f%fquat%f%f%f%fMag%f%f%f%f%f%f%f';
opt = {'Delimiter',{';',':',' '}, 'MultipleDelimsAsOne',true, 'CollectOutput',true};
fid = fopen('Prova_1.txt','rt');
out = textscan(fid,fmt,opt{:});
fclose(fid);
ts = out{1}
out = out{2}
More Answers (0)
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!