Element change in a matrix

11 ビュー (過去 30 日間)
Ricardo jose
Ricardo jose 2021 年 4 月 5 日
回答済み: Steven Lord 2021 年 4 月 5 日
Hello,
I would like to know if its is possible to subtitute elements in a matrix by conditions. Imagine a matrix in where there are number between 1-100, i want to set all value that are under 30 to 0, all between 30 and 75 to 1 and between 75 and 100 to 2, how do i do it? is that even possible? thank you

採用された回答

KSSV
KSSV 2021 年 4 月 5 日
編集済み: KSSV 2021 年 4 月 5 日
Let A be your matrix.
B = A ;
B(B<30) = 0 ; % replace < 30 to 0
B(B>=30 && B<75) = 1 ;
  2 件のコメント
KSSV
KSSV 2021 年 4 月 5 日
@Ricardo jose commented:
Uau, it really worked.
Damn im so gratefull, thank a lot, you saved me ahah.
madhan ravi
madhan ravi 2021 年 4 月 5 日
&& -> &

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2021 年 4 月 5 日
Take a look at the discretize function.

カテゴリ

Help Center および File ExchangeChoose and Parameterize Blocks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by