Passing function with parameters to another function

7 ビュー (過去 30 日間)
Mazin Mustafa
Mazin Mustafa 2017 年 10 月 17 日
コメント済み: KSSV 2020 年 7 月 1 日
Hi,
I am trying to create a function that accepts another function with its own parameters e.g. Func1(@(x)Func2(x,para1,para2,...etc)) Is this possible in Matlab? If yes, how?
  2 件のコメント
Mazin Mustafa
Mazin Mustafa 2017 年 10 月 21 日
I actually found the solution for this. just using the function handle inside the body of the function.

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

回答 (1 件)

KSSV
KSSV 2017 年 10 月 17 日
f1 = @(x,y) x(y) ;
f2 = @(y) sin(y) ;
f1(f2,pi/2)
  3 件のコメント
Amjith Shaheer
Amjith Shaheer 2020 年 7 月 1 日

Why do u have to put a dot in x.^2 + a;.I am new to Matlab

KSSV
KSSV 2020 年 7 月 1 日
If x is an array to get element by element square, you have to put . i.e .^

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by