错误是:all matrices on a row in the bracketed expression must have the same number of rows
程序是:
function [x1 k]=newton
syms x y;
f =((x-2)^4+(x-2*y)^2-5)^2+(x^2-y)^2;
g=jacobian(f,[x,y]);
g=g';
b=jacobian(g,[x,y])
j=1e-5;
grad1=subs(g,{x,y},{0,0});
grad2=subs(b,[x,y],[0,0]);
k=1;
while(norm(grad1)>j)
x=x-inv(grad2)*(grad1);
grad1=subs(g,[x,y],[x(1),y(1)]);
grad2=subs(b,[x,y],[x(1),y(1)]);
k=k+1;
end
在grad1=subs(g,[x,y],[x(1),y(1)]);出现的那个错误,请问应该怎么改?
谢谢!!!!
请问你是说什么的行数不一样呢?