2.1.5句柄函数、匿名函数

% 函数句柄:
% fun = @ Mfun 这里的Mfun是函数的M文件表达方式
fun0 = @calculate
fun0(1,3)
% 匿名函数(类似lambda函数):
% fun = @(x)表达式
fun1 = @(x) x^2 + sin(x+1)
fun1(1)

calculate函数文件为:

function [cos_,sqrt_] = calculate(a,b)
cos_ = cos(a)
sqrt_ = sqrt(b)
end

猜你喜欢

转载自blog.csdn.net/qq_43328166/article/details/108546838