Bonjour,
Je dois coder un petit modèle pour résoudre 4 equa. diff. très facile.
J'ai utiliser la fonction ODE mais mon tuteur m'a demandé de l'écrire sans cette fonction et je ne sais vraiment comment faire, quels sont mes erreurs et comment insérer mes conditions limites..
avec ode
sans odeCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 function dx=test2(t,x) %x=impu,sizes; %x=[0,0,0,0]; %Declaration et initialisation des Constantes impsource=0.2; beta= 1; theta=0.4; s0=2; kdiff=0.2; %Initialisation des dÈrivÈes; dx=zeros(4,1); %Mise en forme canonique des Equa-diff dx(1)= impsource - (kdiff*x(1)); dx(2)= (kdiff*x(1)) - (kdiff*x(2)); dx(3)= beta*x(1) + theta*(s0 - x(3)); dx(4)= beta*x(1) + theta*(s0 - x(4)); end %[T,XSTAT]=ode23(@test2, [0 20], [0 0 0 0.1]) %subplot(2,2,1) %plot(T,XSTAT(:,1)) %subplot(2,2,2) %plot(T,XSTAT(:,2)) %subplot(2,2,3) %plot(T,XSTAT(:,3)) %subplot(2,2,4) %plot(T,XSTAT(:,4))
Alors je me tourne vers vous, j'espere vivement que quelqu'un pourra m'aider à en sortir, d'autant que cela ne semble pas très compliqué.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 clc clear all j=10; dt=6; Source1=3; K1=2; betha=2; tetha=3; taille0=0.5; for n = 1:j %X1 (Impu1): dImpu(1)/dt = Source1 - k*Impu(1) X1=zeros(j,n); X1(n+1)=X1(n)+dt*(Source1-(K1*X1(n))); %X2 (Impu2): dImpu(2)/dt = K1*Impu(1) - K1*Impu(2) X2=zeros(j,n); X2(n+1)=X2(n)+dt*((K1*X1(n)) - (K1*X2(n))); %X3 (taille1): dtaille(1)/dt = betha*Impu(1) + tetha* (taille0 - taille(1)) X3=zeros(j,n); X3(n+1)=X3(n)+dt* ((betha *X1(n)) + ( tetha * ( taille0 - X3(n)))); %X4 (taille2): dtaille(2)/dt = betha*Impu(1) + tetha* (taille0 - taille(2)) X4=zeros(j,n); X4(n+1)= X4(n) + dt* ((betha*X1(n)) + ( tetha * (taille0 - X4(n)))); end X=[X1,X2,X3,X4]; subplot (2,2,1); plot (X1) subplot (2,2,2); plot (X2) subplot (2,2,3); plot (X3) subplot (2,2,4); plot (X4)