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에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!