finding the index of row

25 ビュー (過去 30 日間)
Busy Bee
Busy Bee 2018 年 5 月 19 日
編集済み: Jan 2018 年 5 月 19 日
This is my data set.
y =[107.5000 108.3271 178.2391 37.0000 37.7498 177.1469 177.5000 176.8030 106.7899 36.3059 36.6464 106.2095]
I am using
index=find(y(:,1)==37.7498)
This gives me a null matrix. Why?

回答 (2 件)

Majid Farzaneh
Majid Farzaneh 2018 年 5 月 19 日
Hi. Use this:
index=find(y==37.7495)
Your result is null because you have only one row and you are searching in all rows (one row) and first column. So there is no 37.7495 in your first element.

Jan
Jan 2018 年 5 月 19 日
編集済み: Jan 2018 年 5 月 19 日
While the solution has given by Majid Farzaneh already, remember, that comparisons with floating point values are sensitive for rounding.

カテゴリ

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