-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiagPolar_DanielFonseca.m
89 lines (74 loc) · 2.06 KB
/
DiagPolar_DanielFonseca.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
clear all
close all
clc
eixoy = [-100 30];
eixoy1 = [-300 1];
tempo=0.1; j=100; b=0; maiorMod=0; x1m=0; y1m=0; wr1=0; salvawr=0; modulW=0; mai =0;
salvax1m = 0; salvay1m = 0; salvamaiorMod = 0;
linha=''; pl=''; a=''; yeye='' ; yeye1='';
xx1 = []; yy1 = [];
filename = 'DiagPolar_DanielFonseca.gif';
if exist(filename)
delete(filename)
end
h = figure;
n = logspace(0.5,5,j);
subplot(2,2,[1,3])
xlim([-0.4 1.2])
ylim([-1 1])
title('Diagrama polar','FontSize',15)
xlabel('Re')
ylabel('Im')
grid
hold on
figure(1)
fazBode(n)
h.OuterPosition = [ 0 0 1500 1500];
fazAnotacoes(b, j, modulW, mai, wr1,x1m,y1m);
for b = 1:j
subplot(2,2,[1,3])
s = i*n(b);
g = (1/(1+(1.1*s/500)+(s/500)^2));
x1 = real(g);
y1 = imag(g);
xx1 = [xx1 x1];
yy1 = [yy1 y1];
modulo = abs(g);
if b>1
[wr, x1m, y1m, maiorMod] = achaMaiorModulo(salvawr,...
salvax1m, salvay1m, salvamaiorMod ,modulo, modulo2,n,b,x1,y1); %Descobre maior módulo e Wr
salvawr = wr; salvax1m = x1m; salvay1m = y1m; salvamaiorMod = maiorMod;
wr1 = num2str(wr);
end
modulo2 = modulo;
delete(linha);
delete(pl);
linha = Seta(g);
pl = plot(xx1,yy1,'-ob');
subplot(2,2,2)
delete (yeye);
eixox = n(b).*ones(1,2); %Vetor para varrer diagrama de bode: magnitude
yeye = plot(eixox,eixoy,'r');
xlim([0 100000])
subplot(2,2,4)
delete (yeye1);
eixox1 = n(b).*ones(1,2); %Vetor para varrer diagrama de bode: magnitude
yeye1 = plot(eixox1,eixoy1,'r');
xlim([0 100000])
ylim([-180 1])
modulW = num2str(n(b));
mai = num2str(maiorMod);
delete(a);
a = fazAnotacoes(b, j, modulW, mai, wr1,x1m,y1m);
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if b == j
tempo = 3;
end
if exist(filename) == 0
imwrite(imind,cm,filename,'gif', 'Loopcount',65535,'DelayTime',tempo);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',tempo);
end
end