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

比如这里面的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 Exchange에서 Creating 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!