How to select element of an array between two values?

Hi,
I have an array of 2800 elements < 2800 x 1 double >, and I want to create a new array only with the values that are greater than -0.15 and less than 0.15. Many Thanks in advance.
Regards, Martha

 採用された回答

Walter Roberson
Walter Roberson 2014 年 3 月 24 日

0 投票

A(A > -0.15 & A < 0.15)
or
A(abs(A) < 0.15)

4 件のコメント

Walter Roberson
Walter Roberson 2014 年 3 月 24 日
Multi-column analyzing column 1
A(abs(A(:,1)) < 0.15, :)
Martha
Martha 2014 年 3 月 24 日
Thanks Walter, but if I do that is pretty much the same results as the previous answer. I just want to select the columns 1, 2 & 3 for the results given in the first example. Analyzing the elements between -0.15 & 0.15 from column 1 and selecting the rows that match with that condition but from each of the 3 columns.
Thanks. Martha
Martha
Martha 2014 年 3 月 24 日
My apologies Walter, I tried again and it works perfectly. Thank you very much!
FSh
FSh 2021 年 7 月 17 日
strange it does not work for me ??!!!

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

その他の回答 (1 件)

Martha
Martha 2014 年 3 月 24 日

0 投票

Thanks Walter,
Both work very well! Do you know also how to do the same but with several columns?, That is, having < 2800 x 3 > but analyzing only values from the first column and return the values from the given rows but all the columns.
Thanks
Martha

カテゴリ

質問済み:

2014 年 3 月 24 日

コメント済み:

FSh
2021 年 7 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by