where is the problem

% Resoulision des systèmes non-linéaire
clc
clear
x1=5;
x2=5;
x3=5;
X=[x1;x2;x3];
deltx=1;
k=1;
while abs(deltx)>10^-6
f=[3*X(1)+cos(X(2)*X(3))-1;X(1)^2-81*(X(2)+0.1)^2+sin(X(3))+0.25;exp(-X(1)*X(2))+20*X(3)+9];
j=[3 -X(3)*sin(X(2)*X(3)) -X(2)*sin(X(2)*X(3));2*X(1) -162*(X(2)+0.1) cos(X(3));-X(2)*exp(-X(1)*X(2)) -X(1)*exp(-X(1)*X(2)) 20];
deltx=-inv(j)*f;
X=X+deltx;
k=k+1;
end
format long
racinx1=X(1);
racinx2=X(2);
racinx3=X(3);

4 comentarios

John D'Errico
John D'Errico el 25 de Nov. de 2018
Where is what problem? Does the code not run? Does it result in an error? Does it not do what you want it to do? (If so, then you need to tell people what you think it should be doing.)
Walter Roberson
Walter Roberson el 25 de Nov. de 2018
deltx=1;
So it's a scalar?
deltx=-inv(j)*f;
j is 3 x 3. f is 3 x 1. So inv(j)*f is 3 x 3 * 3 x 1, which is going to give a 3 x 1 result. So after that line, deltx is going to be 3 x 1, not a scalar.
while abs(deltx)>10^-6
Remember that for the purpose of if and while there is an implicit all() so the test is
while all(abs(deltx)>10^-6)
Is that what you want? Or do you want
while any(abs(deltx)>10^-6)
belal hariz belgacem
belal hariz belgacem el 26 de Nov. de 2018
Thank you
The program works
My fault here ..........while abs(deltx)>10^-6
After correction
while all (abs(deltx)>10^-6)
Walter Roberson
Walter Roberson el 26 de Nov. de 2018
Those would be the same thing to MATLAB, it automatically supplies all()

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Preguntada:

el 25 de Nov. de 2018

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by