Index Position 1 is invalid. Newton's method program
显示 更早的评论
When I run the following code, I keep getting errors of either Index Position 1 is invalid or out of range subscript depending on my values for x0. Not sure what to do.
x0=[1,1,1,1,1,1,1,1,1]'; %enter estimates
I defined 9 functions (f1-f9)
J=sym(zeros(9));
for j=1:length(vars) %create Jacobian matrix
J(1,j)=diff(f1,vars(j));
J(2,j)=diff(f2,vars(j));
J(....
end
x=[x0];
for i=1:10
x(:,i+1)=x(:,i)-inv(J(x(1,i),x(2,i),x(3,i),x(4,i),x(5,i),x(6,i),x(7,i),x(8,i),x(9,i)))*f(x(1,i),x(2,i),x(3,i),x(4,i),x(5,i),x(6,i),x(7,i),x(8,i),x(9,i))'; %solve for x
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!