PDA

查看完整版本 : 多步骤匿名功能


poster
2019-12-10, 20:48
我有一个相当复杂的函数,我想将其编写为匿名函数。

看起来像这样:

function Answer = MatlabFunction(x) a=4*x; b=sin(a); c=cos(b); Answer = c; 我不知道如何将其放入匿名函数中。有没有一种方法可以不将其编写为几个级联函数呢?



回答:

有两种方法:

您可以将函数MatlabFunction保存在Matlab路径上,然后将匿名函数定义为

myFun = @MatlabFunction; 或者,您直接将函数定义为

myFun = @(x)cos(sin(4*x));

更多&回答... (https://stackoverflow.com/questions/3673030)