How can i use a for loop based on a row value
显示 更早的评论
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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!