blob: 97450ce4042e20d3c9ab5e4d66df24556d2cdda4 (
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
|
//Chapter 6, Example 6.8
clc
funcprot(0)
//Initialisation
C=200*10**-6 //capacitance in farad
R1=5 //resistance in ohm
R2=50 //resistance in ohm
L=50*10**-3 //inductance in henry
pi=3.14 //pi
w=500 //angular frequency
v=10 //voltage
//Calculation
Z1=R1-(%i*(1/(w*C))) //impedance in complex form
Z2=((R2*w**2*L**2)+(%i*R2**2*w*L))/(R2**2+(w**2*L**2)) //impedance in complex form
Z=Z2/(Z1+Z2) //impedance in complex form
V0=v*Z
function [r,th]=rect2pol(x,y)
//rectangle to polar coordinate conversion
//based on "Scilab from a Matlab User's Point of View", Eike Rietsch,
2002
r=sqrt(x^2+y^2);
th = atan(y,x)*180/%pi;
endfunction
[r,th]=rect2pol(real(V0),imag(V0)) //calling a function
//Results
printf("vo = %.1f sin( %d t + %.1f )",r,w,th)
|