-
Notifications
You must be signed in to change notification settings - Fork 0
/
aval2pt3.m
122 lines (110 loc) · 2.82 KB
/
aval2pt3.m
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
clc
close all
clear
%MA sem compensador
Num = [25];
Den = [1 6 0];
sysMA = tf(Num,Den);
figure
rlocus(sysMA);
%figure
%step(sysMA)
%axis([-7 1 -5 5])
%title('LGR MA sem Gc')
%MF sem compensador
Num1 = [25];
Den1 = [1 6 25];
sysMF = tf(Num1,Den1);
figure
step(sysMF,5);
%title('Resposta ao Degrau MF sem Gc')
%MA com compensador genérico
a=18.75;
Num2 = [25 25*a];
Den2 = [1 6 0];
sysMA1 = tf(Num2,Den2);
figure
rlocus(sysMA1);
title('LGR MA com Gc')
%MF com compensador genérico
Num3 = [25 25*a];
Den3 = [1 31 25*a];
sysMF2 = tf(Num3,Den3);
%figure
%step(sysMF2,3);
%title('Resposta ao Degrau MF com Gc')
%figure
%bode(sysMF)
%title('Bode do sistema sem Gc')
%figure
%bode(sysMF2)
%title('Bode do sistema com Gc')
%MF com controlador Foward diff (Euler)
Tsamp = 0.06;
Numd = [25*Tsamp 25*a*(Tsamp^2)-25*Tsamp]; %[1.125 -0.176];
Dend = [1 (31*Tsamp)-2 25*a*(Tsamp^2)-(31*Tsamp)+1]; %[1 -0.605 0.554];
sysMF2dF = tf(Numd,Dend,Tsamp);
figure
%hold on
step(sysMF2dF);
stepinfo(sysMF2dF)
zplane(Numd,Dend)
title('Forward')
%MF com controlador Backwad diff
Numd1 = [25*a*(Tsamp^2)+25*Tsamp -25*Tsamp 0];
Dend1 = [1+(31*Tsamp)+25*a*(Tsamp^2) -(2+31*Tsamp) 1];
sysMF2dB = tf(Numd1,Dend1,Tsamp);
figure
step(sysMF2dB);
stepinfo(sysMF2dB)
zplane(Numd1,Dend1)
title('Backward')
%MF com controlador Tustin-Bilinear
Numd2 = [25*a*(Tsamp^2)+50*Tsamp 50*a*(Tsamp^2) 25*a*(Tsamp^2)-50*Tsamp];
Dend2 = [4+(62*Tsamp)+25*a*(Tsamp^2) (50*a*(Tsamp^2)-8) 4-62*Tsamp+25*a*(Tsamp^2)];
sysMF2dT = tf(Numd2,Dend2,Tsamp);
figure
step(sysMF2dT);
stepinfo(sysMF2dT)
zplane(Numd2,Dend2)
title('Tustin-Bilinear')
%hold off
%legend('forward','backward','tustin');
Tsamp1 = 0.17; %0.15;
%MA sem compensador discretizado
Numd3 = [0.243 0.128];
Dend3 = [1 -1.407 0.407];
sysMAd = tf(Numd3,Dend3,Tsamp1);
figure
step(sysMAd,80) %80s compara com o sistema contínuo
title('Malha aberta discretizada')
figure
zplane(Numd3,Dend3);
title('Malha aberta discretizada')
Tsamp2 = 0.06;
%MF sem compensador discretizado
Numd4 = [0.243 0.128];
Dend4 = [1 -1.164 0.535];
sysMAd2 = tf(Numd4,Dend4,Tsamp2);
figure
step(sysMAd2,5)
title('Malha fechada discretizada')
figure
zplane(Numd4,Dend4);
title('Malha fechada discretizada')
%confere
digits(4);
syms z a Tsamp;
Tsamp = 0.06; %0.045;
a=18.75;
G(z) = ((25*Tsamp*z+25*a*(Tsamp^2)-25*Tsamp)/((z^2)+((31*Tsamp)-2)*z+25*a*(Tsamp^2)-(31*Tsamp)+1));
disp('G(z)=');
pretty(vpa(G(z)));
%confere
G2(z) = (((25*a*(Tsamp^2)+25*Tsamp)*(z^2)-25*Tsamp*z)/((1+31*Tsamp+25*a*(Tsamp^2))*(z^2)-(31*Tsamp+2)*z+1));
disp('G2(z)=');
pretty(vpa(G2(z)));
%confere
G3(z) = (((25*a*(Tsamp^2)+50*Tsamp)*(z^2)-50*a*(Tsamp^2)*z+25*a*(Tsamp^2)-50*Tsamp)/((4+62*Tsamp+25*a*(Tsamp^2))*(z^2)-(50*a*(Tsamp^2)-8)*z+4-62*Tsamp+25*a*(Tsamp^2)));
disp('G3(z)=');
pretty(vpa(G3(z)));