how to take a function to handle as input

3 visualizaciones (últimos 30 días)
dila
dila el 25 de Abr. de 2014
Comentada: Mohammad Rehan Khan el 13 de En. de 2022
Hi;
i have a code which evaluates a function "f". but i want to take this "f" as input.
it is like;
f=@ input('please enter the predefined function name')
but this is not valid. is any way to do this ? thanks.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 25 de Abr. de 2014
Editada: Azzi Abdelmalek el 25 de Abr. de 2014
Use str2func function
str=input('your function','s')
f=str2func(str)
  3 comentarios
Razan alhammad
Razan alhammad el 10 de Abr. de 2020
how i put it value in this function because also i have mistake when i put it variable in f(..)
Mohammad Rehan Khan
Mohammad Rehan Khan el 13 de En. de 2022
how to give arguement?

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by