Having issues assigning my output vector in the function below. When I try to call output vector x1(k) I get the error listed. I solved this issue before in my other output 'ex(1)' by using absolute value. Not sure what notation issue is with x1(1).
1 次查看(过去 30 天)
显示 更早的评论
Error at line x1(1) = x + y/jac
In an assignment A(I) = B, the number of elements in B and I must be the same.
function [x1,numIts,ex]=newton(f2,x,maxIts)
% [x,numIts]=newton(func,x,maxIts)
% func is a function handle with signature [y,yprime]=func(x)
N = 10
x = ones(N,1);
x= transpose(x);
x1 = transpose(ones(N,1));
f2 = f1(x);
maxIts=100;
if nargin < 3
maxIts=100; % default value if maxIts is omitted
end
E = 10e-6;
maxIts = 100
k = 2
[y,jac]=f1(x)
y = abs(y(x))
jac = jac(x)
x1(1) = x + y/jac
ex(1) = abs(norm(x - x1(1)))
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!