Extract specific values and row coloumn information in matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
i have a matrix with size of 270x560 and has a value from 0 to 7 in it.
i want to extract a values of 5 in this matrix and also an information about the location (row and column) of these value in 270x560 matrix
is there any reference to do it?
here is some code that i already tried
x = B(:,:) ;
y = B(:,:) ;
z = x(y==5)
also i tried using find function but the result shows some random numbers
out = find(B == 5);
댓글 수: 0
채택된 답변
추가 답변 (1개)
Star Strider
2022년 1월 31일
Try this —
M = randi([0 7], 5, 6) % Example Matrix
[r,c] = find(M == 5); % r = Row, c = Column, For Each Occurrence
row_col = [r c] % Matching Row, Column References
.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!