请问分段函数,该如何编写。

比如这里面的Cw=350, Ww=40,I是已知矩阵
那么Cw-Ww/2=330 Cw+Ww=350
其中Im是要得出的矩阵 I作为一个矩阵变量 也就是说让I中矩阵所有的数 每个都做一次运算 然后根据分段函数 得出 矩阵Im 请问如何编程 不剩感激
直接我写的是
I(I<=40)=0
I (I>=350) =255
但是中间那个以矩阵作为变量的矩阵就不会写了 虚心请教大神!!

 採用された回答

jajiso
jajiso 2022 年 11 月 19 日

0 投票

Cw-Ww/2=330;
Cw+Ww/2=370;
Im=0.*(I<=330)+255*(I-350+40/2)/40.*(I>330&I<370)+255.*(I>=370);

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2022 年 11 月 19 日

回答済み:

2022 年 11 月 19 日

Community Treasure Hunt

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

Start Hunting!