How to find specific elements in a matrix
이전 댓글 표시
Good Day,
I have a matrix: R55 = [2,4,6,9,11;7,8,9,10,6;1,2,6,4,5;,6,9,8,5,6;1,6,5,7,5];
I would like to find the specific locations of all the 6's (rows and colums) using a for loop and using logical matrices rather than using just the "find" function.
채택된 답변
추가 답변 (1개)
Walter Roberson
2022년 11월 8일
0 개 추천
This kind of task is usually easier to write with nested for loops over size() of the array. If you are required to use a single for loop then loop over the linear indices and ind2sub to translate to row and column
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!