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

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

 Réponse acceptée

jajiso
jajiso le 19 Nov 2022

0 votes

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);

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!