SIMULATION MATLAB
Exercice 1
3.
function dudt=cruise_speed(t, u)
C=15*1e-9;
B=0.01;
I=3;
dudt=I/C-(B/C)*u;
u0= 0 ;
[t,v]=ode45('cruise_speed', [0 10],u0) ;
plot(t,v) ;
grid on ;
title('cruise speed time response to a constant traction force Fa(t)')
dsolve("Du=I/C-(B/C)*u", "v(0)=0")
R=100;
C=15*1e-9;
I1=3;
A=1;
B=1e-7;
D=6.67*1e8;
alpha=(R*C*I1)/(R+C);
beta=-(1/(R*C));
%Question 4
s=tf('s') ;
H= D/(B+A*s)
%Question 5
t = 0 :0.01 :8;
%step(H)
%Question 6
syms t s
u = alpha*(1-exp(beta*t));
U = laplace (u,t,s);
disp(U)
%[R,P,K]= residue(U)
Exercice 3
3. N.B. : Pour chaque cas la fonction sera ecrit dans un script et la fonction dans l’autre partie
du script
Pour r=2
function dXdt=mass_spring1(t, X)
M=750 ;
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^2+Fa/M ;
1|Page
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring1', [0 200],X0) ;
plot(t,X) ;
title('r=2');
grid on ;
Pour r=3
function dXdt=mass_spring2(t, X)
M=750
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^3+Fa/M ;
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring2', [0 200],X0) ;
plot(t,X) ;
title('r=3');
grid on ;
Pour r=4
function dXdt=mass_spring3(t, X)
M=750
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^4+Fa/M ;
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring3', [0 200],X0) ;
plot(t,X) ;
title('r=4');
grid on ;
4.
N.B: Ecrire dans des scripts différents les 04 fonctions ci dessous
function dXdt=mass_spring(t, X)
M=750 ;
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^1+Fa/M ;
2|Page
function dXdt=mass_spring1(t, X)
M=750 ;
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^2+Fa/M ;
function dXdt=mass_spring2(t, X)
M=750
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^3+Fa/M ;
function dXdt=mass_spring3(t, X)
M=750
B=30 ;
Fa=300 ;
K=15 ;
dXdt(1,1)=X(2);
dXdt(2,1)=-B/M*X(2)-K/M*(X(1))^4+Fa/M ;
La partie du code ci dessous sera ecrit dans un nouveau script
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring', [0 200],X0) ;
subplot(2,2,1);
plot(t,X) ;
title('r=1');
grid on ;
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring1', [0 200],X0) ;
subplot(2,2,2);
plot(t,X) ;
title('r=2');
grid on ;
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring2', [0 200],X0) ;
subplot(2,2,3);
plot(t,X) ;
title('r=3');
grid on ;
X0=[0 ; 0] ;
options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on') ;
[t,X]=ode45('mass_spring3', [0 200],X0) ;
subplot(2,2,4);
plot(t,X) ;
title('r=4');
3|Page
grid on ;
Exercice 4
m=0.14;
R=1500;
wo=5288;
a=1/(wo)^2;
b=(2*m)/(wo);
H=tf([0 0 1],[a b 1]); % Fonction de transfert
% Obtention de la réponse indicielle
[y, t] = step(H);
plot(t, y, 'b', 'LineWidth', 1.5);
grid on;
xlabel('Temps (s)');
ylabel('Réponse');
title('Réponse indicielle d’un système du second ordre');
hold on;
% Dépassement (D)
y_final = y(end);
y_max = max(y);
D = ((y_max - y_final) / y_final) * 100;
plot(t(y == y_max), y_max, 'ro', 'MarkerFaceColor', 'r');
text(t(y == y_max), y_max, sprintf(' D = %.2f%%', D), 'FontSize', 12,
'Color', 'r');
disp(['Dépassement : ', num2str(D), ' %']);
% Temps du premier pic (T_p)
[~, idx_max] = max(y);
T_p = t(idx_max);
plot([T_p, T_p], [0, y_max], 'r--');
text(T_p, y_max/2, sprintf('T_p = %.2f s', T_p), 'FontSize', 12, 'Color',
'r');
disp(['Temps du premier pic : ', num2str(T_p), ' s']);
% Temps de montée (T_m)
t_m10 = t(find(y >= 0.1 * y_final, 1));
t_m90 = t(find(y >= 0.9 * y_final, 1));
T_m = t_m90 - t_m10;
plot([t_m10, t_m10], [0, y_final], 'g--');
plot([t_m90, t_m90], [0, y_final], 'g--');
text(t_m90, y_final * 0.5, sprintf('T_m = %.2f s', T_m), 'FontSize', 12,
'Color', 'g');
disp(['Temps de montée : ', num2str(T_m), ' s']);
Exercice 5
s=tf('s');
G=(6*s^2+1)/(s^3+3*s^2+3*s+7);
%Question 1
subplot(2,2,1);
sgrid;
pzmap(G)
4|Page
%Question 2
subplot(2,2,2);
impulse(G)
%Question 3
s=tf('s');
%H=s*G
H=(6*s^3+s)/(s^3+3*s^2+3*s+7)
subplot(2,2,3);
step(H)
5|Page