How can i use sscanf values?

1 vue (au cours des 30 derniers jours)
Marco
Marco le 6 Fév 2014
Commenté : Walter Roberson le 6 Fév 2014
Hello there,
i have a code like this:
if tline(1) == 'e'
[data,count]= sscanf(tline,'%c, %d, %d, %d, %d, %d, %d, %d, %d',inf);
if count == 7
fprintf(' element %d : tipo %d , material %d , seccao %d , no I %d , no J %d\n',...
data(2),data(3),data(4),data(5),data(6),data(7));
nelementos= nelementos+1;
elementos(1,data(2))= data(3);
elementos(2,data(2))= data(4);
elementos(3,data(2))= data(5);
elementos(4,data(2))= data(6);
elementos(5,data(2))= data(7);
end
end
that read a file like this:
e, 1, 1, 2, 3, 1, 1, 1
e, 2, 2, 3, 1, 1, 1
e, 3, 3, 4, 1, 1, 1,1
the file can have the Var 'e' how much is possible.
how can i use the value of each and i can i now and use de number of e rows that appear me?

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Fév 2014
I do not understand what you mean by "how can i use the value of each" ?
The count of the number of lines is your nelementos variable.
  2 commentaires
Marco
Marco le 6 Fév 2014
Sorry my english.
i mean, how can I use the data for each line of 'e', those 1 , 2, 3...
Walter Roberson
Walter Roberson le 6 Fév 2014
You stored them as columns in elementos.
elementos(:,K)
would be the list of values for the K'th line.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by