summaryrefslogtreecommitdiff
path: root/671/CH4/EX4.8/4_8.sce
blob: db1a96dcaaa1d7e425abbe2bc53c74c26fb2dc6e (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
38
39
40
41
function [r,theta]=cart_to_polar(z)
    x=real(z)
    y=imag(z)
    r=norm(z)
    theta=atan(y/x)
endfunction

function [x,y]=polar_to_cart(zpolar)
    r=real(zpolar)
    theta=imag(zpolar)/180*%pi
    x=r*cos(theta)
    y=r*sin(theta)
endfunction

function Zeq=parallel(Z1,Z2)
    Zeq=Z1*Z2/(Z1+Z2)
endfunction

R=200
L=0.5
C=50E-6
w=200

Xl=w*L*%i
Xc=1/(w*C*%i)

////////////////////////////part a
Ir=complex(0.02*cos(30*%pi/180),0.02*sin(30*%pi/180))
V=Ir*R
Il=V/Xl
Ic=V/Xc
I=Ir+Il+Ic
disp(I)

////////////////////////////part b
[Ix,Iy]=polar_to_cart(complex(2,-40))
I=complex(Ix,Iy)
Zin=parallel(parallel(R,Xc),Xl)
V=Zin*I
Ir=V/R
disp(V,Ir)