-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshunt_singlestub.m
153 lines (103 loc) · 3.34 KB
/
shunt_singlestub.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
prompt = 'What is Z0 ';
Z0 = input(prompt);
prompt = 'What is stub charecteristic impeadance? ';
Zs=input(prompt);
prompt = 'What is ZL ';
ZL=input(prompt);
RL=real(ZL);
XL=imag(ZL);
syms lamda;
Y1=1/Zs;
if ( RL == Z0)
t = -XL/(2*Z0);
if ( t >= 0 )
d=vpa(atan(t)/(2*pi),4)
G= (RL*(1+t^2))/(RL^2+(XL+Z0*t)^2);
B= ((RL^2)*t - (Z0-XL*t)*(XL+Z0*t))/ (Z0*(RL^2 + (XL+Z0*t)^2));
lo = ( -atan(B/Y1) / (2*pi));
ls = (atan(Y1/B) / (2*pi));
while(lo <0)
lo=lo+0.5;
end
while(ls <0)
ls=ls+0.5;
end
lo
ls
else
d=vpa((pi+atan(t))/(2*pi),4)
G= (RL*(1+t^2))/(RL^2+(XL+Z0*t)^2);
B= ((RL^2)*t - (Z0-XL*t)*(XL+Z0*t))/ (Z0*(RL^2 + (XL+Z0*t)^2));
lo = ( -atan(B/Y1) / (2*pi));
ls = (atan(Y1/B) / (2*pi));
while(lo <0)
lo=lo+0.5;
end
while(ls <0)
ls=ls+0.5;
end
lo
ls
end
else
t1= (XL + sqrt(RL*((Z0-RL)^2 +XL^2) / Z0)) / (RL-Z0);
t2= (XL - sqrt(RL*((Z0-RL)^2 +XL^2) / Z0)) / (RL-Z0);
if ( t1 >= 0 )
d1=vpa(atan(t1)/(2*pi),4)
G= (RL*(1+t1^2))/(RL^2+(XL+Z0*t1)^2);
B= ((RL^2)*t1 - (Z0-XL*t1)*(XL+Z0*t1))/ (Z0*(RL^2 + (XL+Z0*t1)^2));
lo1 = ( -atan(B/Y1) / (2*pi));
ls1 = (atan(Y1/B) / (2*pi));
while(lo1 <0)
lo1=lo1+0.5;
end
while(ls1 <0)
ls1=ls1+0.5;
end
lo1
ls1
else
d1=vpa((pi+atan(t1))/(2*pi),4)
G= (RL*(1+t1^2))/(RL^2+(XL+Z0*t1)^2);
B= ((RL^2)*t1 - (Z0-XL*t1)*(XL+Z0*t1))/ (Z0*(RL^2 + (XL+Z0*t1)^2));
lo1 = ( -atan(B/Y1) / (2*pi));
ls1 = (atan(Y1/B) / (2*pi));
while(lo1 <0)
lo1=lo1+0.5;
end
while(ls1 <0)
ls1=ls1+0.5;
end
lo1
ls1
end
if ( t2 >= 0 )
d2=vpa(atan(t2)/(2*pi),4)
G= (RL*(1+t2^2))/(RL^2+(XL+Z0*t2)^2);
B= ((RL^2)*t2 - (Z0-XL*t2)*(XL+Z0*t2))/ (Z0*(RL^2 + (XL+Z0*t2)^2));
lo2 = ( -atan(B/Y1) / (2*pi));
ls2 = (atan(Y1/B) / (2*pi));
while(lo2 <0)
lo2=lo2+0.5;
end
while(ls2 <0)
ls2=ls2+0.5;
end
lo2
ls2
else
d2=vpa((pi+atan(t2))/(2*pi),4)
G= (RL*(1+t2^2))/(RL^2+(XL+Z0*t2)^2);
B= ((RL^2)*t2 - (Z0-XL*t2)*(XL+Z0*t2))/ (Z0*(RL^2 + (XL+Z0*t2)^2));
lo2 = ( -atan(B/Y1) / (2*pi));
ls2 = (atan(Y1/B) / (2*pi));
while(lo2 <0)
lo2=lo2+0.5;
end
while(ls2 <0)
ls2=ls2+0.5;
end
lo2
ls2
end
end