Verfasst am: 20.06.2011, 15:32
Titel: use newton methode deal with a non linear (equation system)
I cant get that followed picture that what i need. S1(i) without result be shown on the matlab.
may be newton methode and funktion F and jacobi JF should be separate writen on the matlab.
but how to wirte a funtion for the matrix
%%Gitter erstellung
N=50;
M=50;
k=T/(N+1); %Timestep;
h=(Xmax-1)/(M+1); %stockstep;
X=[X0:h:Xmax];
%% Boundary Condition % final condition for j=1:M+2
f1(j,N+1)=0;
end
%freiei randwert
S1(N+1)=K;
%
for i=1:N+1
f1(M+2,i)=0;
end
%%%Definition von f1(1,i)und f1(2,i) for i=1:N
f1(1,i)=K-S1(i);
f1(2,i)=K-(1+h)*S1(i);
end;
%%Berechnung S1,f1(1,i),f1(2,i)
%%Rechnung a1,b1,c1(Parameters) für model
for j=2:M+1
a1(j)=1+k/(h^2)*vol^2*X(j)^2+r*k;
for i=1:N
b1(j)=(-k)/(2*h^2)*vol^2*X(j)^2+k/(2*h)*X(j)*(r-(S1(i+1)-S1(i))/(k*S1(i)));
c1(j)=(-k)/(2*h^2)*vol^2*X(j)^2-k/(2*h)*X(j)*(r-(S1(i+1)-S1(i))/(k*S1(i)));
end end
%%Set up Matrix A
A=zeros(M,M);
for j=2:M-1
A(j-1,j-1)=c1(j);
A(j,j-1)=a1(j+1);
A(j+1,j-1)=b1(j+2);
end
A(M-1,M-1)=c1(M);
A(M,M-1)=a1(M+1);
%
disp('es ist A')
%%Set up y
y=zeros(M,1);
for j=2:M
y(j-1,1)=f1(j+1,i) end
y(M,1)=S1(i)
%%%Set up G
G=zeros(M,1);
for i=1:N
for j=3:M
G(j,1)=f1(j+1,i+1) end
G(1,1)=f1(2,i+1)-b1(2)*(K-S1(i))-a1(2)*(K-(1+h)*S1(i));
G(2,1)=f1(3,i+1)-b1(3)*(K-(1+h)*S1(i));
end
%%%%Set up Nichtlinear gleichung F
F=A*y-G
disp('es ist F')
%%%erstellung Jacobbi Matrix von F
%% set up ableitung von a1,b1,c1__a2 b2 c2 for j=2:M+1
a2(j)=0;
for i=1:N
b2(j)=X(j)*S1(i+1)/(2*h*S1(i)^2);
c2(j)=-X(j)*S1(i+1)/(2*h*S1(i)^2);
end end
%Set up ableitung von A nach S1: A1
A1=zeros(M,M);
for j=2:M-1
A1(j-1,j-1)=c2(j);
A1(j+1,j-1)=b2(j+2);
end
A1(M-1,M-1)=c2(M);
%%%set up Ableitung von G
G1=zeros(M,1);
for i=1:N
G1(1,1)=-(b2(2)*(K-S1(i))-b1(2))+a1(2)*(1+h);
G1(2,1)=-K*b2(3)+(1+h)*(b1(3)+b2(3)*S1(i));
end
%%Jacobi Matrix Fs
F1=A1*y-G1;
Fs=[A,F1];
disp('es ist Fs') disp(Fs)
%%%inverse von Jacobbi Fs
%Fs1=inv(Fs);
%%%NEUTON Verfahren
%%% einer gegebenen Funktion y
y=y1;q=1;
whileabs(F)>error; q=q+1;
ifabs(Fs)<error||q>N1;
disp('Ableitung gleich null oder Anzahl N der Interationen überschritten');
break;
end;
y=y-F/Fs;
end;
I would like to use Implicit methode to deal with none parabolic system and use Newton's method
ich want solve A(S1(i))*f1(:,i) = G(S1(i)),
followed F(f1(:,i),S1(i))=A(S1(i))*f1(:,i)-G(S1(i))=0;
to be y=(f1(3,i) ,......,f1(M+1,i),S1(i));
and then with iterative Method(Newton's method) y(k+1)=y(k)-F(y(k))/J(F(y(k));
** J(F(y(k)))is Jacobi Matrix, i need to find f1(1,i),....f1(M+1,i) and S1(i)
In the result to find f1(:,1) und S1(i), that´s mean in point 0all of f1(:,1) and
Value of S1(i)forall point of time. And the diagram should the above showed picture.
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.