How to limit an input within a specific range?

조회 수: 4 (최근 30일)
Khalil Ishaq
Khalil Ishaq 2017년 1월 6일
답변: Adam 2017년 1월 6일
In the code below, I am willing to set min and max value for u so if it exceeded that limit it will either return the max or the min value.
K1=1/.1;
K2=10;
E=E+(Cos-Com)*dt;
u=(-V/Com)*((YOSan-YOSen)*(-Yx*(qM-(Com*Sm*qsMax)/((Com+Ko)*(Sm*Sm/Ki+Sm+Ks))))*(0.96/0.375)+YOSen*((Com*Sm*qsMax)/((Com+Ko)*(Sm*Sm/Ki+Sm+Ks)))-kLa*(Costar-Com)+ K1*(Cos-Com) + K2*E);
uplot(k,:)=u; % this is just for the visualisation ate the end
u = min(......

채택된 답변

Adam
Adam 2017년 1월 6일
u = min( someMax, max( someMin, u ) );

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Verification, Validation, and Test에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by