Passing function with parameters to another function

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

回答(1 个)

KSSV
KSSV 2017-10-17
f1 = @(x,y) x(y) ;
f2 = @(y) sin(y) ;
f1(f2,pi/2)
  3 个评论
KSSV
KSSV 2020-7-1
If x is an array to get element by element square, you have to put . i.e .^

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by