Borrar filtros
Borrar filtros

switch between subfunctions

1 visualización (últimos 30 días)
azarm
azarm el 24 de Ag. de 2011
Hi hi,
i have a main function that includes many other sub functions inside. I want to switch between subfunction,i.e. block some of them and run the others. Any idea how to make it?
function main ()
.
function1 ()
function2 () . .
end
Tnx,
Azarm

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 24 de Ag. de 2011
use switch or if..end, e.g.:
function funmain(..., p1)
function funs1()
...
end
function funs2()
...
end
... % 1 or 2 variant
end
% 1 variant
switch p1
case case_expr1
... = funs1();
case case_expr2
... = funs2();
end
% 2 variant
if p1 == expr (or strcmp(p1,expr)...)
... = funs1();
else
... = funs1();
end
  1 comentario
azarm
azarm el 24 de Ag. de 2011
tnx, didn'n notice that it works for functions too:)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by