How can i use a for loop based on a row value
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!