问题如下:
在Octave中实现伊利诺伊州版本的regula falsi方法。函数的签名是
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
)
提示:http://en.wikipedia.org/wiki/False_position_method#Illinois_algorithm
我想问:
如何为此问题在 Matlab 函数中输入实数函数?
例如,假设我正在 1 到 3 之间搜索 x^2-4 中的根,所以它在 GUI 上的功能应该是
illinois(x^2-4, 1, 3, 0.1, 1000)
我如何告诉 matlab/octave 这个"数字函数"x^2-4,或者我错误地解释了这个问题?
看看函数句柄:
http://www.gnu.org/software/octave/doc/interpreter/Function-Handles.html
您可以使用f=@(x)(x.^2-2)
定义函数,使用g(f,1,2,3,4)
将其传递给另一个函数,并像其他函数一样对其进行f(1)
。