load txt file

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 ExchangeData 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