textscan only reads first row of text file
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Simone Ricci
il 7 Nov 2021
Commentato: Simone Ricci
il 7 Nov 2021
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 Commenti
Risposta accettata
Stephen23
il 7 Nov 2021
Modificato: Stephen23
il 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}
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Text Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!