how to take a function to handle as input

5 views (last 30 days)
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.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 25 Apr 2014
Edited: Azzi Abdelmalek on 25 Apr 2014
Use str2func function
str=input('your function','s')
f=str2func(str)
  3 Comments
Razan alhammad
Razan alhammad on 10 Apr 2020
how i put it value in this function because also i have mistake when i put it variable in f(..)

Sign in to comment.

More Answers (0)

Categories

Find more on Function Handles in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!