How do I find the indices of the value of my matrix?

2 ビュー (過去 30 日間)
Farshid Daryabor
Farshid Daryabor 2019 年 12 月 16 日
コメント済み: Farshid Daryabor 2019 年 12 月 18 日
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

採用された回答

Stephen23
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

その他の回答 (5 件)

KALYAN ACHARJYA
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
Stephen23 2019 年 12 月 16 日
This is not robust and does not work for the provided value:
>> any(XX(:) == -69.19)
ans = 0

サインインしてコメントする。


Farshid Daryabor
Farshid Daryabor 2019 年 12 月 16 日
the commend tried before does not work,
idx=find(XX == -69.19);
idx = []

Farshid Daryabor
Farshid Daryabor 2019 年 12 月 16 日
I actually looking for an individual index (idx) for the corresponding value, as same for the latitude (idy). by the finding the indices I want to find a data as arranged based on the lon and lat,
data = var(idx,idy);

Farshid Daryabor
Farshid Daryabor 2019 年 12 月 16 日
Dear Stephen,
the second one is exactly what I am looking for. It's possible explaine why abs(XX - (-69.19)) should less than (1e-n), and how is defined 'n'
[R,C] = find(abs(XX - -69.19)<1e-3)
R = 25
C = 124

Farshid Daryabor
Farshid Daryabor 2019 年 12 月 16 日
the problem is when I want to find the certain variable from the matrix arranged based on the longitude and latitude, how can I find it by having the corresponding indices
Data=Data(y,x)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by