Borrar filtros
Borrar filtros

a function insdie a switch case

15 visualizaciones (últimos 30 días)
Bader Herzallah
Bader Herzallah el 23 de Abr. de 2020
Respondida: Steven Lord el 23 de Abr. de 2020
how can i put a functon code inside a switch case
  1 comentario
Ameer Hamza
Ameer Hamza el 23 de Abr. de 2020
Can you further describe what you want you are trying to do?

Iniciar sesión para comentar.

Respuesta aceptada

Steven Lord
Steven Lord el 23 de Abr. de 2020
You cannot define a function inside a switch-case statement as stated on this documentation page.
"You cannot define a nested function inside any of the MATLAB® program control statements, such as if/elseif/else, switch/case, for, while, or try/catch."
If you want your nested function to be nested inside the function that contains the switch-case statement, define it nested inside that function but outside all control statements
You can call functions inside a case or otherwise section of a switch-case statement or to generate the expression on which you switch. The examples on the documentation page for the switch keyword show this using disp, bar, title, pie3, and warning. So does this example:
switch input('Enter a number: ')
case 1
disp('The One')
otherwise
warning('Not The One')
end

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps 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