summaryrefslogtreecommitdiff
path: root/2414/CH3/EX3.5/Ex3_5.sce
blob: bc0bfacc4c6bf343e0c9ea3a908b3f5c53f776d6 (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
clc;
clear all;
//chapter 3
//page no 86
//example 3.5
A=20;    //Volts
T=5*10^-3;    //period in seconds
tau=1*10^-3;   //pulse width in second
d=tau/T;        //duty cycle
f1=1/T;        //Fundamental frequency in Hz

//for plot
n=[-14:15];    //in Hz
Vf=[]
for i=1:length(n)
    if n(i)==0 then
        Vf(i*200)=A*d;
    else
       Vf(i*200)=A*d*sin(%pi*d*n(i))/(%pi*d*n(i)) 
    end
    //to get the magnitudes of components
    if Vf(i*200)<0 then
        Vf(i*200)=-Vf(i*200)
    end
  
end
f=-3000:3000-1
clf;
plot2d(f,Vf,[5],rect=[-3000,0,3000,5])
a=gca(); // Handle on axes entity
a.x_location = "origin"; 
a.y_location = "origin";

xtitle('Amplitude Spectrum','f,Hz','Vn');
xgrid