问题标签 [function-handle]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
374 浏览

matlab - MATLAB: Function Handle of Nested Function

Is there a way to create a function handle to a nested function that includes the parent function in the function handle?

As an example, say I have:

In another file, I could call the method by doing something like:

But, if I have another function that takes function handles as a parameter and then calls the function, how do I pass in the function handle to myMethod in this case, since this new function can't create a myParent variable.

0 投票
1 回答
48 浏览

matlab - 在matlab中绘制两个句柄函数的差异

我有两个handle-functions,它们的图表非常接近,我可以通过绘制两个函数来看到这一点。

我想要另一个图表来区分f-ff

我怎么能在matlab中做到这一点?我怎样才能找到:

当两者都是句柄功能时?
提前致谢!

PS。只要让我知道我是否应该添加更多关于fand的信息ff

0 投票
1 回答
67 浏览

arrays - 如何通过函数句柄构建数组

我正在尝试使用函数句柄在 MATLAB 中生成类似的东西

答案应该是:

但是当我在下面编写这段代码时,它只是构建一个数字而不是一个数组。

回答:

有人可以解释我哪里出错了吗?

0 投票
1 回答
2143 浏览

matlab - 将函数句柄应用于多个输入参数

我在 MATLAB 中定义了一个矩阵和一个向量:

以及一个接受这些类型的输入参数的函数:

但是,我想使用此函数的函数句柄将其应用于我的值。我以为我可以用cellfun这个,但是:

给出错误:

我该如何正确地做到这一点?

0 投票
1 回答
598 浏览

matlab - 函数句柄单元的累积和

我有一个函数句柄单元:

N在这里是一个很大的数。在所有这些函数句柄上执行累积和的最方便的方法是什么?例如,我想要一个新函数 g{} 的单元格:

谢谢。

0 投票
3 回答
56 浏览

matlab - how can I pass an argument to a function handle, but interpret it only on call time?

What I want to do is:

Instead, I only get 6! On several other tests I ran, I get that a is evaluated when foo is, and and not when foo is called.

For various reasons, I can't work with

0 投票
1 回答
1807 浏览

matlab - MATLAB - Integral 2 - 第一个输入参数必须是函数句柄

我需要使用integral2()带有语法的函数:q = integral2(fun, xmin , xmax, ymin , ymax).

我已经尝试了以下命令:

(已定义xmin, xmax, ymin, ymax

但我得到一个错误:

有人可以帮助并解释我做错了什么吗?

0 投票
1 回答
196 浏览

matlab - 在 Matlab 中调用单独的函数

我试图调用一个允许用户输入他们选择的方程的函数,然后使用一个单独的函数在数值分析中使用梯形规则来近似它。

这是我的用户输入方程的代码:

这是应用梯形规则的代码:

我的问题是尝试使用由第一个函数确定的方程作为第二个函数的输入。

0 投票
1 回答
591 浏览

matlab - 在 MATLAB 中将函数名称作为参数传递

我知道这个问题已经在这里提出并得到了回答,但我无法让它发挥作用。

我有一个简单的函数 f1 :

我想要一个以函数名作为输入的“委托”函数。下面你可以看到我的 2 次试验:

当我在命令窗口中调用它时,它们都给出了相同的错误:

我究竟做错了什么?

谢谢你的帮助 !

0 投票
2 回答
512 浏览

matlab - matlab中的计算函数

有什么方法可以使用工具箱在matlab中计算一个函数?例如我有这个函数:f(x,y)=x^2+y^2,我想设置 x=2 和 y=2 并且函数取回 8。我该怎么做?谢谢