textscan only reads first row of text file
조회 수: 12 (최근 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!