textscan only reads first row of text file
13 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Stephen23
2021 年 11 月 7 日
編集済み: Stephen23
2021 年 11 月 7 日
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}
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!