blob: ca01c39f5128148b9e60d52e7d4467ab130509e1 (
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
|
clc;
clear all;
//chapter 3
//page no 75
//example 3.1
A=1 //arbitrary value provided
T=10 //T represents tau (arbitrary value provided)
//plot for non periodic pulse
t=-2*T:.001:2*T;
vt=[zeros(-2*T:.001:-T/2) A*ones(-T/2+.001:.001:T/2-.001) zeros(T/2:.001:2*T)]
clf
subplot(211)
plot2d(t,vt,[2],rect=[-2*T,0,2*T,A+1])
xtitle('(a) Non periodic pulse','t','v(t)')
//plot for amplitude spectum
f=-4/T:.001:4/T;
Vf=[]
for i=1:length(f)
if f(i)==0 then
Vf=[Vf A*T]; //according to L'Hopitals rule sin(x)/x=1 at lim x->0
else
Vf=[Vf A*T*sin(%pi*f(i)*T)/(%pi*f(i)*T)]
end
end
subplot(212)
plot2d(f,Vf,[5])
xtitle('(b) Amplitude spectrum','f','V(f)')
xgrid
|