필터 지우기
필터 지우기

converting values from conditional to single equation

조회 수: 2 (최근 30일)
Ali Najem
Ali Najem 2020년 12월 15일
댓글: Ali Najem 2020년 12월 16일
Hi all
I need to convert this if condition to one equation
let's assume we have this if statment
if x>=0
f = x(i);
else
f = 0.2*(exp(x)-1);
end
can I re-write if statment in one equation ?
Any suggestion would be appreciated

채택된 답변

Alan Stevens
Alan Stevens 2020년 12월 15일
One possibility
f = x(i)*(x(i)>=0) + 0.2*(exp(x(i)) - 1)*(x(i)<0);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by