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?

 Réponse acceptée

Jan
Jan le 24 Mar 2011

2 votes

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

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Centre d'aide et File Exchange

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by