-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample3_02.m
More file actions
59 lines (41 loc) · 1004 Bytes
/
Example3_02.m
File metadata and controls
59 lines (41 loc) · 1004 Bytes
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% File: Example3_03.m for Example 3-2
clear;
% Spectrum of Flat-top Sampled PAM.
% Assume analog waveform has a rectangular spectrum with
% bandwidth B
B = 5;
fs = 15;
Ts = 1/fs;
f = -10:1:100;
W = zeros(length(f),1);
W = PULSE(W,f,-B,B);
n = 0:1:6;
% d is the sample pulse width divided by the sampling period.
d = 1/3;
tau = d*Ts;
x = pi*tau*f;
H = SA(x);
% Generating spectrum of Flat-top Pulse PAM signal.
Ws = zeros(length(f),1);
% Generating Shifted versions of W due to sampling.
for (i = 1:1:length(n))
Wtemp = zeros(length(f),1);
for (j = n(i)*fs+1:1:length(W))
Wtemp(j) = W(j - n(i)*fs);
end;
Ws = Ws + Wtemp;
end;
Ws = Ws.*H*fs;
subplot(211);
plot(f,abs(W));
xlabel(' f (Hz) -->');
ylabel('|W(f)|');
axis([-20 20 0 1.5]);
title('Magnitude Spectrum for the Analog Signal');
subplot(212);
plot(f,abs(Ws));
xlabel('f (Hz) -->');
ylabel('|Ws(f)|');
axis([0 100 0 18]);
title(['Magnitude Spectrum of Flat-top Sampled PAM Signal for f>0, fs=',num2str(fs)]);