Borrar filtros
Borrar filtros

Improving an if else function

1 visualización (últimos 30 días)
Natialol
Natialol el 28 de Mzo. de 2013
Respondida: AKARSH KUMAR el 24 de Jun. de 2020
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 comentarios
Cedric
Cedric el 28 de Mzo. de 2013
Editada: Cedric el 28 de Mzo. de 2013
What is the code where you put the 3 dots?
Natialol
Natialol el 29 de Mzo. de 2013
Editada: Natialol el 29 de Mzo. de 2013
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

Iniciar sesión para comentar.

Respuestas (1)

AKARSH KUMAR
AKARSH KUMAR el 24 de Jun. de 2020
I don't think this if else condition could further be reduced, try to check in your other part of code.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by