Filter Matrix over a specific value

data = [1:10];
idx = data > 5;
%output only logical values
I want to filter my values, aim would be to get all values in a matrix that are bigger than 5 and everything below should be "deleted".
So the new dimension for this example would be 1x4 [6,7,8,9,10].
How can I implement this?

1 件のコメント

Stijn Haenen
Stijn Haenen 2022 年 6 月 14 日
Like this?
data=1:10;
new_data=data(data>5);

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

 採用された回答

Dyuman Joshi
Dyuman Joshi 2022 年 6 月 14 日

1 投票

The new dimension would be 1x5, not 1x4
data=1:10
data = 1×10
1 2 3 4 5 6 7 8 9 10
data(data>5)
ans = 1×5
6 7 8 9 10

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品

リリース

R2020b

質問済み:

2022 年 6 月 14 日

回答済み:

2022 年 6 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by