so I have a txt file containing data like this
1st row 1 2 3 2nd row 4 5 6 3rd row 7 8 9
I want to load the data in a loop it will read the values in the row eg. a=1 b=2 c=3
and subsequently load the 2nd row and the 3rd row.
how do I do this?

 채택된 답변

Jan
Jan 2011년 3월 24일

2 개 추천

FID = fopen(FileName, 'r');
while ~feof(FID)
Line = fgetl(FID);
if ischar(Line)
D = sscanf(Line, '%g');
a = D(1);
b = D(2);
c = D(3);
... % The calulations here
end
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

제품

태그

질문:

Hoa
2011년 3월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by