MATLAB: Load txt file

load txtMATLAB

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?

Best Answer

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