error finding placement of specific number in a vector

1 回表示 (過去 30 日間)
Candice Cooper
Candice Cooper 2021 年 5 月 25 日
コメント済み: Candice Cooper 2021 年 5 月 25 日
I have a single column vector named 'lon' of 8640 values. I'm trying to find which row has a certain value. I've tried using find(lon==120), but all it returns is an empty 0 x 1 double column vector. I've tried figuring this out online, but all I come across is the find function, which isn't working for me.

採用された回答

DGM
DGM 2021 年 5 月 25 日
編集済み: DGM 2021 年 5 月 25 日
Does the vector contain 120?
Does the vector contain exactly 120?
If it's floating point, the answer might not be what you think it is.
A = linspace(0,10,19).'
A = 19×1
0 0.5556 1.1111 1.6667 2.2222 2.7778 3.3333 3.8889 4.4444 5.0000
find(A == 3.3333)
ans = 0×1 empty double column vector
find(abs(A-3.3333)<1E-3)
ans = 7

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 25 日
Hi,
Your data might be in a floating point format and if that is the case, then you need to be careful with logical indexing. If this is the case, you may need to use round up, select how many correct decimal digits to consider, and so forth. Moreover, inftead of find(Ion==120), you can use IND = (Ion==120) that shows you the indexes.
If you post your data, more specific answer will be provided.
Good luck.

カテゴリ

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