问题如下:
在奥克塔夫实施伊利诺伊州版本的正规法。函数的签名是
illinois(
f, % a real numeric function
a, % left bound of search interval
b, % right bound of search interval
yAcc, % accuracy in the y-dimsension
nIter % maximum number of iterations
)
提示:algorithm
我想问:
对于这个问题,我如何在Matlab函数中输入一个真正的数值函数呢?
例如,假设我在1到3之间的x^2-4中搜索根,所以它应该是GUI上的函数。
illinois(x^2-4, 1, 3, 0.1, 1000)
我如何告诉matlab/八度这个‘数字函数’x^2-4,或者我错误地解释了这个问题?
发布于 2014-02-18 17:56:04
看看函数句柄:
http://www.gnu.org/software/octave/doc/interpreter/Function-Handles.html
您可以使用f=@(x)(x.^2-2)
定义函数,使用g(f,1,2,3,4)
将其传递给另一个函数,并像其他函数f(1)
一样对其进行计算。
https://stackoverflow.com/questions/21861579
复制相似问题