function [y,n]=mulsimNewton(F,x0,eps)
if nargin==2, eps=10^-6; end
x0=transpose(x0); Fx=subs(F,findsym(F),x0);
dF=Jacobian(F); c=subs(dF,findsym(dF),x0);
inv(c)
y=x0-Fx*inv(c); n=1; tol=1;
while tol>eps
x0=y; Fx=subs(F,findsym(F),x0);
y=x0-inv(c)*Fx; tol=norm(y-x0); n=n+1;
if (n>10^10), disp('迭代次数大于最大值,可能不收敛'); return; end
end
function y=F(x)
y=[x(1)-0.7*sin(x(1))-0.2*cos(x(2));x(2)-0.7*cos(x(1))+0.2*sin(x(2))];
y=[y(1) y(2)];
这是错误提示
Warning: Function call F invokes inexact match D:\work\f.m.
??? Input argument "x" is undefined.
Error in ==> f at 2
y=[x(1)-0.7*sin(x(1))-0.2*cos(x(2));x(2)-0.7*cos(x(1))+0.2*sin(x(2))];
[ 本帖最后由 ChaChing 于 2009-5-14 21:00 编辑 ] |