Académique Documents
Professionnel Documents
Culture Documents
for i=1:n;
k1=h*func(x(i),t(i));
k2=h*func(x(i)+k1/2,t(i)+h/2);
k3=h*func(x(i)+k2/2,t(i)+h/2);
k4=h*func(x(i)+k3,t(i)+h);
[T,X]=RungeKutta(@func,x0,t)
Plot(T,X) %faire représenter les résultats
sur un plan.
EXEMPLE SUR LA MÉTHODE:
%le programme principal
clc;clear;
[t,x]=RungeKutta(@func,1,[0 4])
plot(t,x)
xlabel('temps')
ylabel('X')
title('variation de x en fonction de t')
%la fonction
function out=func(x,t)
out=t.^2-x.^2;
end
LE GRAPHE OBTENU SUR
MATLAB
variation de x en fonction de t
4
3.5
2.5
X
1.5
0.5
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5
temps