How do I find the indices of the value of my matrix?
조회 수: 2 (최근 30일)
이전 댓글 표시
How can I find the indices and exactly position of the value of the attached file. For example find index of value = -69.19 from the attached file.
Thanks
댓글 수: 0
채택된 답변
Stephen23
2019년 12월 16일
The answer depends entirely on how you define "equals" for floating point numbers:
>> [R,C] = find(abs(XX - -69.19)<1e-4)
R = []
C = []
>> [R,C] = find(abs(XX - -69.19)<1e-3)
R = 25
C = 124
>> [R,C] = find(abs(XX - -69.19)<1e-2)
R =
3
6
10
14
17
18
21
25
29
32
C =
108
110
113
116
118
119
121
124
127
129
댓글 수: 0
추가 답변 (5개)
KALYAN ACHARJYA
2019년 12월 16일
편집: KALYAN ACHARJYA
2019년 12월 16일
Load the mat file, say as data variable
idx=find(data==-69.19)
Please read about floating number precision (Must)
Example:
>> A=[1 -69.19 3.5 10];
>> idx=find(A==-69.19)
idx =
2
댓글 수: 1
Stephen23
2019년 12월 16일
This is not robust and does not work for the provided value:
>> any(XX(:) == -69.19)
ans = 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!