Not enough input arguments.
Mostra commenti meno recenti
Bonjour
Je commence à programmer sur MATLAB et j'arrive pas à comprendre l'origine de cette erreur. J'essaie de programmer la méthode de Newton Raphson pour résoudre un système d'équation assez compliqué. Mon programme est composé de trois scripts:
-newtonm: la methode de Newton Raohson
function [x,iter] = newtonm(x0,f,J)
N = 100; % define max. number of iterations
epsilon = 1e-10; % define tolerance
maxval = 10000.0; % define value for divergence
x0 = [1;1;1;1]; % load initial guess
xx=x0;
while (N>0)
JJ = feval(J,xx);
if abs(det(JJ))<epsilon
input('erreur');
abort;
end;
xn = xx - inv(JJ)*feval(f,xx);
if abs(feval(f,xn))<epsilon
x=xn;
iter = 100-N;
return;
end;
if abs(feval(f,xx))>maxval
iter = 100-N;
disp(['iterations = ',num2str(iter)]);
error('Solution diverges');
abort;
end;
N = N - 1;
xx = xn;
end;
error('No convergence after 100 iterations.');
abort;
% end function
-jacob4x4: Le jacobian de mon système
function [J] = jacob4x4(x)
J(1,1) = 1; J(1,2) = 0;
J(1,3) =(A*(X1+((1/6)*(X1^2)*(2*x(4)+2*x(3)))))/((1+(X1*(x(4)+x(3)))+(1/6)*(X1^2)*(x(4)+x(3))^2)^2);
J(1,4) =(A*(X1+((1/6)*(X1^2)*(2*x(4)+2*x(3)))))/((1+(X1*(x(4)+x(3)))+(1/6)*(X1^2)*(x(4)+x(3))^2)^2);
J(2,1) = 0; J(2,2) = 1;
J(2,3) = (B*(-X2+((1/6)*(X2^2)*(-2*x(4)+2*x(3)))))/((1+(X2*(x(4)-x(3)))+(1/6)*(X2^2)*(x(4)-x(3))^2)^2);
J(2,4) = (B*(X2+((1/6)*(X2^2)*(2*x(4)-2*x(3)))))/((1+(X2*(x(4)-x(3)))+(1/6)*(X2^2)*(x(4)-x(3))^2)^2);
J(3,1)=-(2*D2*D1*x(2))/((x(2)*D1+x(1)*D2)^2); J(3,2)=(2*D2*D1*x(1))/((x(2)*D1+x(1)*D2)^2); J(3,3)=1/x(4); J(3,4)=-x(3)/(x(4)^2);
J(4,1)=(2*D2*D1*x(2))/((x(2)*D1+x(1)*D2)^2); J(4,2)=-(2*D2*D1*x(1))/((x(2)*D1+x(1)*D2)^2); J(4,3)=-1/x(4); J(4,4)=x(3)/(x(4)^2);
%end function
-f4: Mon système
function [f] = f4(x)
f1 = x(1)-A*((1+(X1*(x(4)+x(3)))+(1/6)*(X1^2)*(x(4)+x(3))^2)^(-1));
f2 = x(2)-B*((1+(X2*(x(4)-x(3)))+(1/6)*(X2^2)*(x(4)-x(3))^2)^(-1));
f3 = 1+(x(3)/x(4))-2/(1+(x(2)*D1)/(x(1)*D2));
f4 = 1-(x(3)/x(4))-2/(1+(x(1)*D2)/(x(2)*D1));
f = [f1;f2;f3;f4];
% end function
Sachant que j'ai déjà déclaré les constantes nécessaires dans le fichier main de ma fonction.
La méthode est fonctionnelle pour un système simple d'ordre 2.
Merci d'avance :)
4 Commenti
Walter Roberson
il 18 Ago 2015
C'est necessaire de ons rire votre functions
Nouhayla EL GHANI
il 18 Ago 2015
Walter Roberson
il 18 Ago 2015
You have not shown your code or command to call newtonm
Nouhayla EL GHANI
il 19 Ago 2015
Modificato: Nouhayla EL GHANI
il 19 Ago 2015
Risposte (1)
Walter Roberson
il 19 Ago 2015
0 voti
1 Commento
Nouhayla EL GHANI
il 20 Ago 2015
Categorie
Scopri di più su Newton-Raphson Method in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!