[英]Error using fzero in Matlab: Undefined function or method 'det' for input arguments of type 'function_handle'
[英]Undefined function 'NR' for input arguments of type '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;
尝试通过以下输入使用该功能时,它将返回以下错误消息
NR(func,dfunc,-1)类型为'function_handle'的输入参数的未定义函数'NR'。
我究竟做错了什么? 在此先感谢您的帮助。
确保您的matlab的工作目录/路径具有NR功能
如果不需要的话,你可以做
addpath('path_where_NR_is');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.