[英]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.