Matlab 函数处理程序

Matlab 函数处理程序,matlab,function,function-handle,Matlab,Function,Function Handle,我在matlab上使用了两个不同的函数:function1和function2(每一个都用不同的脚本编写) 在function1的脚本中,我有如下内容: function result = function1(y,z) result = function2(@(x)do_this(x,y,z), @(f)do_that(f,y,z)) function f = do_this(x,y,z) f = operationOn(x,y,z) end function d = do_that(f,x

我在matlab上使用了两个不同的函数:function1和function2(每一个都用不同的脚本编写)

在function1的脚本中,我有如下内容:

function result = function1(y,z)

result = function2(@(x)do_this(x,y,z), @(f)do_that(f,y,z))

function f = do_this(x,y,z)
f = operationOn(x,y,z)
end
function d = do_that(f,x,z)
d = operationOn(f,y,z)
end

end
在function2的脚本中,我有:

function otherResult = function2(do_this, do_that)
m = matrix;
p = do_this(m)
otherResult = do_that(p)
end
我发现function2有一个问题,因为每当我试图显示p(函数的结果在脚本1中定义),我得到的值都是NaN

我看不出问题出在哪里?我是否以错误的方式使用函数处理程序


感谢您的帮助

您正确使用了函数句柄,因此这里生成
NaN
值的唯一原因似乎是
operationOn
。它有什么作用?@如果你是对的,问题在于手术。事实上,这个运算涉及到指数运算,我认为这些值太大了。我会仔细研究一下的!:)