-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotSinCosPhasor.m
181 lines (139 loc) · 2.54 KB
/
plotSinCosPhasor.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
clear all;close all;clc;
w=1;
dt=1e-3;
T=2*pi/w;
t=(-T:dt:3*T)';
u1=cos(w*t);
figure
for idx=1:4
hpl(idx)=subplot(2,2,idx);
end
subplot(2,2,1)
plot(t,u1,'k')
hold on
grid on
xlabel('tempo')
ylabel('sinusoidi')
ylim([-3 3])
xlim(t([1 end]))
subplot(2,2,2)
stem(w,1,'k')
hold on
grid on
xlabel('pulsazione')
ylabel('ampiezza')
ylim([-3 3])
xlim([0 2])
xlim('manual')
subplot(2,2,4)
stem(w,0,'k')
hold on
grid on
xlabel('pulsazione')
ylabel('fase')
ylim([-360 360])
xlim([0 2])
xlim('manual')
subplot(2,2,3)
hold on
grid on
xlabel('Re')
ylabel('Im')
xlim([-2 2])
ylim([-2 2])
hq=quiver(0,0,1,0,'k');
set(hq,'MaxHeadSize',1e2,'AutoScaleFactor',1);
axis equal
axis manual
pause
pha=deg2rad(0);
amp=1;
u2=amp*cos(w*t+pha);
subplot(2,2,1)
h1=plot(t,u2,'r');
h5=plot([0,pha/w],[2.5 2.5],'--b');
h6=plot([0,0],[1 2.5],'--b');
h7=plot([pha/w,pha/w],[amp 2.5],'--b');
subplot(2,2,2)
h2=stem(w,amp,'r');
subplot(2,2,4)
h3=stem(w,rad2deg(pha),'r');
subplot(2,2,3)
h4=quiver(0,0,amp*cos(pha),amp*sin(pha),'r');
set(h4,'MaxHeadSize',1e2,'AutoScaleFactor',1);
for angolo=0:5:360
pha=deg2rad(angolo);
amp=1;
u2=amp*cos(w*t+pha);
h5.XData=[0 -pha/w];
h7.XData=[-pha/w -pha/w];
h7.YData=[amp 2.5];
h1.YData=u2;
h2.YData=amp;
h3.YData=angolo;
h4.UData=amp*cos(pha);
h4.VData=amp*sin(pha);
pause(0.1)
if angolo==45
pause
end
end
for angolo=360:-5:-75
pha=deg2rad(angolo);
amp=1;
u2=amp*cos(w*t+pha);
h1.YData=u2;
h2.YData=amp;
h3.YData=angolo;
h4.UData=amp*cos(pha);
h4.VData=amp*sin(pha);
h5.XData=[0 -pha/w];
h7.XData=[-pha/w -pha/w];
h7.YData=[amp 2.5];
pause(0.1)
end
%%
for ampiezza=1:0.02:2
pha=deg2rad(angolo);
amp=ampiezza;
u2=amp*cos(w*t+pha);
h1.YData=u2;
h2.YData=amp;
h3.YData=angolo;
h4.UData=amp*cos(pha);
h4.VData=amp*sin(pha);
h7.XData=[-pha/w -pha/w];
h7.YData=[amp 2.5];
pause(0.1)
end
for ampiezza=2:-0.02:0.1
pha=deg2rad(angolo);
amp=ampiezza;
u2=amp*cos(w*t+pha);
h1.YData=u2;
h2.YData=amp;
h3.YData=angolo;
h4.UData=amp*cos(pha);
h4.VData=amp*sin(pha);
h7.XData=[-pha/w -pha/w];
h7.YData=[amp 2.5];
pause(0.1)
end
%%
angolo=0;
amp=1;
for omega=1:0.02:2
pha=deg2rad(angolo);
w=omega;
u2=amp*cos(w*t+pha);
h1.YData=u2;
h2.YData=amp;
h2.XData=w;
h3.YData=angolo;
h3.XData=w;
h4.UData=amp*cos(pha);
h4.VData=amp*sin(pha);
h7.XData=[-pha/w -pha/w];
h7.YData=[amp 2.5];
pause(0.1)
end