-
Notifications
You must be signed in to change notification settings - Fork 0
/
1B.txt
44 lines (44 loc) · 1.15 KB
/
1B.txt
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
Wp=28;
Bp=4;
Wg=5;
Bg=1;
z=0:0.05:30;
t=0:0.05:30;
pause(2);
for ti=1:length(t)
for zi=1:length(z)
E1(zi)=cos((Wp+Wg)*t(ti)-(Bp+Bg)*z(zi));
E2(zi)=cos((Wp-Wg)*t(ti)-(Bp-Bg)*z(zi));
E(zi)=2*cos(Wp*t(ti)-Bp*z(zi))*cos(Wg*t(ti)-Bg*z(zi)); %E1+E2
En(zi)=2*cos(Wg*t(ti)-Bg*z(zi));
end
pause(0.05);
subplot(3,1,1);
plot(z,E1,"r");
xlabel('Z-Variation');
ylabel('Wave-1 [E1(z)]');
hold on
plot((Wp+Wg)/(Bp+Bg)*t(ti),1,'o',"MarkerFaceColor","red");
hold off
subplot(3,1,2);
plot(z,E2,"b");
xlabel('Z-Variation');
ylabel('Wave-2 [E2(z)]');
hold on
plot((Wp-Wg)/(Bp-Bg)*t(ti),1,'o',"MarkerFaceColor","blue");
ylim([-1,1]);
hold off
subplot(3,1,3);
plot(z,E,"k");
hold on
plot(z,En,'--k',z,-En,'--k');
plot(Wg/Bg*t(ti),2,'o',"MarkerFaceColor","g");
x=Wp/Bp*t(ti);
v=2*cos(Wg*t(ti)-Bg*x);
plot(x,v,'o',"MarkerFaceColor","blue");
hold off
xlabel('Z-Variation');
ylabel('E(z)=E1(z)+E2(z)');
title('\color{blue}Phase Velocity \color{black}> \color{green}Group Velocity')
drawnow limitrate;
end