choose which function to run it

How can i make user choose which function that will be called
Ex: to run function 1 please enter 1
to run function 2 please enter 2 ..etc

 Respuesta aceptada

Chunru
Chunru el 7 de Mayo de 2021
You can use switch:
f = input('Which function to use? ');
switch f
case 1
func1;
case 2
func2;
otherwise
error('Wrong choice');
end
Of cource, you can also use if..elseif..else..end

Más respuestas (0)

Categorías

Más información sobre Author Block Masks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Mayo de 2021

Comentada:

el 18 de Oct. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by