Improving an if else function

Hello Board,
Anyone on ideas on a more efficient solution than the if else function below?? This takes the bulk of the time for the code so I need to reduce it.
function result = vre(t,r,e.......)
if (t==4 && r>0)
result = 0;
elseif (e==4 && r==0)
result = 1;
.
.
.
end
end
Thanks

댓글 수: 2

Cedric
Cedric 2013년 3월 28일
편집: Cedric 2013년 3월 28일
What is the code where you put the 3 dots?
Natialol
Natialol 2013년 3월 29일
편집: Natialol 2013년 3월 29일
The full function is
function result = vre(t,r,e,n,d)
if (e==4 && r>0)
result = 0;
elseif (e==4 && r==0)
result = 1;
elseif (e<4 && r==1)
result = t;
elseif (e<4 && r==2)
result = d;
else
result=n;
end
end
Thanks

댓글을 달려면 로그인하십시오.

답변 (1개)

AKARSH KUMAR
AKARSH KUMAR 2020년 6월 24일

0 개 추천

I don't think this if else condition could further be reduced, try to check in your other part of code.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2013년 3월 28일

답변:

2020년 6월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by