How can i use a for loop based on a row value
Afficher commentaires plus anciens
I had an original matix;
A = [ 1 a b c
2 d e f
3 g h i
4 j k l ]
which i sorted by rows as;
A = [ 1 a b c
3 g h i
2 d e f
4 j k l ]
later on a for loop i want to use a specific value from A (sorted), based on the first value of each row, and not based in the number of the iteraition.
for examble
for i = 1:3
B (i) = A(i,2)
endfor
when i = 2 (second iteration)
it will return the value g ( A(2,2) ), but i want it to show the value; d ,which is the second value of the row with first corresponding number.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!