Search a given row array in a matrix and get position
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to find the ch = ones(1,9)*178 row array in a large matrix. In that matrix, the number 178 on its own appears in many positions but I want to find the positions when the 9-element array with 178 occurs. If the matrix were A=[0 0 0 0 0 0 0 0 0 178 0 0 0 0 0; 1 2 5 3 2 4 178 5 6 2 2 2 2 2 2; 0 2 178 178 178 178 178 178 178 178 178 0 2 3 2]; the result should be row = 3, column =3. I guess ismember must be in the code but I can´t figure out how... Thanks!
댓글 수: 0
채택된 답변
KSSV
2021년 10월 11일
A=[0 0 0 0 0 0 0 0 0 178 0 0 0 0 0; 1 2 5 3 2 4 178 5 6 2 2 2 2 2 2; 0 2 178 178 178 178 178 178 178 178 178 0 2 3 2];
ch = ones(1,9)*178 ;
for i = 1:size(A,1)
idx = strfind(A(i,:),ch)
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!