how to take a function to handle as input

3 次查看(过去 30 天)
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.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-4-25
编辑:Azzi Abdelmalek 2014-4-25
Use str2func function
str=input('your function','s')
f=str2func(str)

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by