Borrar filtros
Borrar filtros

hello, i want to solve a nonlinear matrix using newton Raphson method but i have some problems with my code. does anybody know what and where is the problem?

1 visualización (últimos 30 días)
function y=newtonsistema
xo=[0;0;0];
syms x y z
mi = rand;
fname=[1/pi*(cos(x)-cos(y)+cos(z))- mi;cos(5*x)-cos(5*y)+cos(5*z);cos(7*x)-cos(8*y)+cos(7*z)];
fprima=(jacobian(fname));
tolerancia=1.e-10;
maxiter = 20;
iter = 1;
f=inline(fname);
jf=inline(fprima);
error=norm(f(xo(1),xo(2),xo(3)),2);
fprintf('error=%12.8f\n', error);
while error >= tolerancia
fxo=f(xo(1),xo(2),xo(3));
fpxo=jf(xo(1),xo(2),xo(3));
x1=xo-pinv(fpxo)*fxo;
fx1=f(x1(1),x1(2),x1(3));
error =norm((fx1),2);
fprintf(' Iter %2d raiz x=(%14.9f,%14.9f,%14.9f) f(x)=(%14.9f,%14.9f,%14.9f)\n',iter,x1(1),x1(2),x1(3),fx1(1),fx1(2),fx1(3));
if iter > maxiter
fprintf('Max number of iter' \n');
return;
end
xo=x1;
iter=iter+1;
if true
% code
end
end
  2 comentarios
Matt J
Matt J el 10 de Dic. de 2017
i want to solve a nonlinear matrix using newton Raphson method but i have some problems
You have neglected to describe them...

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by