how to take a function to handle as input

6 ビュー (過去 30 日間)
dila
dila 2014 年 4 月 25 日
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)
  3 件のコメント
Razan alhammad
Razan alhammad 2020 年 4 月 10 日
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 2022 年 1 月 13 日
how to give arguement?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Handles についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by