summaryrefslogtreecommitdiff
path: root/2210/CH3/EX3.18/3_18.sce
blob: 502dff3d4179154d376d0758aa4721b90b93df9a (plain)
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
//Chapter 3, Prblem 18,
clc
funcprot(0)
// A = p2z(R,Theta) - Convert from polar to rectangular form.
//    R is a matrix containing the magnitudes
//    Theta is a matrix containing the phase angles (in degrees).
function [A] = p2z(R,Theta)
 A = R*exp(%i*%pi*Theta/180);
endfunction

// [R1, Theta1] = z2p(A1) - Display polar form of complex matrix.
function [R1, Theta1] = z2p(A1)
     Theta1 = atan(imag(A1),real(A1))*180/%pi;
     R1=sqrt(real(A1)^2+imag(A1)^2)
endfunction


//transistor S-parameter
s11=p2z(0.12,-10)
s12=p2z(0.002,-78)
s21=p2z(9.8,160)
s22=p2z(0.01,-15)

[s11m,s11a]=z2p(s11)
[s22m,s22a]=z2p(s22)
[s21m,s21a]=z2p(s21)
[s12m,s12a]=z2p(s12)

vswr=(1+s11m)/(1-s11m)
ret_loss=-20*log10(s11m)
Fig=20*log10(s21m)
Rig=20*log10(s12m)

printf("(a) Input VSWR = %.2f\n\n",vswr)
printf("(b) Return loss (dB) = %.2f dB\n\n",ret_loss)
printf("(c) Forward insertion gain = %.2f dB\n\n",Fig)
printf("(d) Reverse insertion gain = %.2f dB\n\n",Rig)