Improving an if else function

1 次查看(过去 30 天)
Natialol
Natialol 2013-3-28
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
I don't think this if else condition could further be reduced, try to check in your other part of code.

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by