How to find index range of range of values in an array

57 ビュー (過去 30 日間)
jess Kapin
jess Kapin 2021 年 4 月 5 日
コメント済み: Are Mjaavatten 2021 年 4 月 6 日
I have an array of one row and 163495 columns. The values in this array range from 0-160. I am trying to find the indices that the values are from 69-72. When I use the find x==69, it computes out an empty array.
  1 件のコメント
jess Kapin
jess Kapin 2021 年 4 月 5 日
It works for any integers (0 and 160 in this case) but I cannot use it for any non-integers

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

回答 (1 件)

Are Mjaavatten
Are Mjaavatten 2021 年 4 月 5 日
i = find(x>=69 & x<=72);;
  2 件のコメント
jess Kapin
jess Kapin 2021 年 4 月 5 日
this results in: i = 1×0 empty double row vector
and when I click on the vector it just says val =
and the rest is blank.
I think this may be because they are not integers? So they are not exactly 69 and 72?
Are Mjaavatten
Are Mjaavatten 2021 年 4 月 6 日
My suggestion should work for both integers and non-integers. As a demonstration, try:
y = 60:0.3:80;
i = find(y>=69 & y<=72)
y(i)
Your result seems to indicate that x contains no values in the specified range.
Are you sure x contains what you think? Try, e.g.;
x(1:100)
to see if the values look right.

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

カテゴリ

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