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?

4 ビュー (過去 30 日間)
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 件のコメント
Matt J
Matt J 2017 年 12 月 10 日
i want to solve a nonlinear matrix using newton Raphson method but i have some problems
You have neglected to describe them...
Torsten
Torsten 2017 年 12 月 11 日
Remove the line
syms x y z
Best wishes
Torsten.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeNewton-Raphson Method についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by