Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
how to find the index for the following code
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
If A=1:10,%A= 1 2 3 4 5 6 7 8 9 10
But I want to display the index of A using for loop.
Could anyone help me to solve the issue.
3 commentaires
Rik
le 19 Fév 2019
Can't you just use A as an index?
someData=[5 8 7 4 6 9 3 10 7 2];
A=5;
disp(someData(5))%shows the 5th element (6 in this case)
%or in a loop:
for A=1:10
disp(someData(A))
end
Réponses (1)
madhan ravi
le 20 Fév 2019
Modifié(e) : madhan ravi
le 20 Fév 2019
“But I want to display the index of A using for loop”
You don’t need one , see the documentation of fprintf().
Values=rand(1,10); % example data
A=1:numel(Values); %indices
fprintf('When A = %d the value is %d\n',[A;Values])
0 commentaires
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!