MATLAB:Input argument "x" is undefined.
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/15 23:43:11
MATLAB:Input argument "x" is undefined.
原代码如下
f02.m
function [f,J] = systemEqns(x)
f(1,1) = x(1)^2+x(2)^2-4.0;
f(2,1) = x(1)^2/10+x(2)^2-1;
if nargout > 1
% Jacobian matrix of the function
J(1,1) = 2.0*x(1);
J(1,2) = 2.0*x(2);
J(2,1) = x(1)/5.0;
J(2,2) = 2.0*x(2);
end
newton_syst.m
function c = newton_syst(fn,xinit,maxit,tolX,tolF)
%
% c = newton_syst('fn',xinit,maxit,tolX,tolF)
%
% Compute the root c such that f(c)=0 using Newton's method starting
% from xinit up to the point where | x_n - x_n+1 | < tolX or |f(x_n)| < tolF
% or the number of iteration exceeds maxit.
%
% 'fn' is the vector function contained in fn.m,a file in a directory
% of the MATLAB path.fn returns [f,G] with f the value of the function
% and G the Jacobian matrix of the function.
%
% initialize values
x = xinit';
[f,J] = feval(fn,x);
iteration = 0;
deltaX = 100.0; % || x_n - x_n+1 || is set to any large value to avoid stopping program
normF = norm(f,inf);
% display of iterates
disp('iteration |X_n - X_n-1| |f(X_n)|')
disp(sprintf('%d %16.14f %16.14f ',iteration,deltaX,normF))
% iterations
while (deltaX>tolX) & (normF>tolF) & (iteration> x=[1;1]
x =
1
1
>> newton_syst(f02,x,100,1e-10,1e-10)
newton方法解非线性方程组
为什么显示
Input argument "x" is undefined.
Error in ==> f02 at 2
f(1,1) = x(1)^2+x(2)^2-4.0;
原代码如下
f02.m
function [f,J] = systemEqns(x)
f(1,1) = x(1)^2+x(2)^2-4.0;
f(2,1) = x(1)^2/10+x(2)^2-1;
if nargout > 1
% Jacobian matrix of the function
J(1,1) = 2.0*x(1);
J(1,2) = 2.0*x(2);
J(2,1) = x(1)/5.0;
J(2,2) = 2.0*x(2);
end
newton_syst.m
function c = newton_syst(fn,xinit,maxit,tolX,tolF)
%
% c = newton_syst('fn',xinit,maxit,tolX,tolF)
%
% Compute the root c such that f(c)=0 using Newton's method starting
% from xinit up to the point where | x_n - x_n+1 | < tolX or |f(x_n)| < tolF
% or the number of iteration exceeds maxit.
%
% 'fn' is the vector function contained in fn.m,a file in a directory
% of the MATLAB path.fn returns [f,G] with f the value of the function
% and G the Jacobian matrix of the function.
%
% initialize values
x = xinit';
[f,J] = feval(fn,x);
iteration = 0;
deltaX = 100.0; % || x_n - x_n+1 || is set to any large value to avoid stopping program
normF = norm(f,inf);
% display of iterates
disp('iteration |X_n - X_n-1| |f(X_n)|')
disp(sprintf('%d %16.14f %16.14f ',iteration,deltaX,normF))
% iterations
while (deltaX>tolX) & (normF>tolF) & (iteration> x=[1;1]
x =
1
1
>> newton_syst(f02,x,100,1e-10,1e-10)
newton方法解非线性方程组
为什么显示
Input argument "x" is undefined.
Error in ==> f02 at 2
f(1,1) = x(1)^2+x(2)^2-4.0;
f02.m————这个改名为systemEqns,函数名最好和文件名一样
function [f,J] = systemEqns(x)
newton_syst(f02,x,100,1e-10,1e-10)
把f02改为@systemEqns 你传递的是函数,不是函数运算出来的值
改好后即可运行了,当然又会出现些其它错误,你自己继续处理好了.
________________________________
算了,我还是讲出来吧
xnew = x-J\f;
改为
xnew = x-(J\f)';
再问: V5 谢啦~
function [f,J] = systemEqns(x)
newton_syst(f02,x,100,1e-10,1e-10)
把f02改为@systemEqns 你传递的是函数,不是函数运算出来的值
改好后即可运行了,当然又会出现些其它错误,你自己继续处理好了.
________________________________
算了,我还是讲出来吧
xnew = x-J\f;
改为
xnew = x-(J\f)';
再问: V5 谢啦~
MATLAB:Input argument "x" is undefined
MATLAB:Input argument "x" is undefined.
matlab问题?Input argument 'X' is undefined.
matlab Input argument "x" is undefined.
matlab?Input argument "a" is undefined.
matlab老是显示input argument '' is undefined
matlab ? Input argument "t" is undefined.
matlab运行结果Input argument "A" is undefined.
matlab错误:Input argument "x" is undefined.Error in ==> overla
matlab程序运行出现?Input argument "x" is undefined.Error in ==> my
MATLAB报错,为什么?Input argument "x" is undefined.Error in ==> m1
在用matlab解微分方程时提示如下信息:Input argument "y" is undefined.Error i