Hello, I'm having trouble figuring out how to replace values in a matrix that fall between two values.
For example, lets say i have matrix, and i want to replace all values that fall between 20 and 50 with -3 instead, how would I go about doing that?

 採用された回答

Adam Danz
Adam Danz 2021 年 2 月 6 日

1 投票

Use basic Matlab indexing.
M(M>20 & M<50) = -3;

1 件のコメント

Naoufel Farid
Naoufel Farid 2021 年 2 月 6 日
Thank you this worked great!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索

製品

リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by