1
我正在写一个简单的函数来查找用户定义的方程的根。该函数如下:未定义函数'NR'用于类型为'function_handle'的输入参数。 MATLAB
function [root] = NR(func, dfunc, x_0)
x_r = x_0;
while func(x_r) > 10^-6
x_r = x_0 - func(x_0)/dfunc(x_0);
x_0 = x_r;
end
root = x_r;
fprintf('The root in the given interval is %.4f\n', root)
我定义我的函数 'FUNC' 和它的衍生物如下 'dfunc'
FUNC = @(X)2 * X^2-3; dfunc = @(x)4 * x;
当试图使用具有以下输入的功能,它返回下列错误messaage
NR(FUNC,dfunc,-1) 未定义的函数 'NR' 的输入 类型为'function_handle'的参数。
我在做什么错?预先感谢您的帮助。
类型'这NR'。谢谢。 – chappjc