-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample6_05.m
More file actions
77 lines (63 loc) · 1.78 KB
/
Example6_05.m
File metadata and controls
77 lines (63 loc) · 1.78 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% File: Example6_05.m for Example 6-5
clear;
clf
% Set values for data autocorrelation function . For example,
% evaluate the spectrum for a Bipolar RZ and NRZ Line Codes using the
% autocorrelation values given (3-44).
% Note that R(i) corresponds to R{subscript i-1}. Therefore,
% R(1) is the autocorrelation function evaluated at zero time shift.
% Using the fact that R(-k) = R(k) to simplify evaluation
Rb = 1;
Tb = 1/Rb;
df = 0.02*Rb;
f = 0:df:3*Rb;
% ------------------------------------------------------------
% For RZ
A = 2;
R = [A^2/2 -(A^2)/4 0 0 0 0];
x = (pi*Tb/2)*f;
F = 0.5*Tb*SA(x);
% Generating PSD of the RZ Bipolar Line Code using (6-70a)
P = zeros(length(f),1);
for (i = 1:1:length(f))
P(i) = (abs(F(i)))^2/Tb;
temp = 0;
for (k = 2:1:length(R))
temp = temp + R(k)*cos(4*(k-1)*x(i));
end;
P(i) = P(i)*(R(1)+2*temp);
end;
fprintf('\nRefer to (3-44) for the R(k) of a Bipolar line code.\n');
fprintf('\nSee Window for the PSD of RZ and NRZ Bipolar Line Codes\n');
fprintf('where Rb = %g',Rb)
fprintf(' bits/sec.\n\n');
subplot(211)
plot(f,P);
xlabel('f in Hz -->');
ylabel('P(f)');
title(['PSD of Bipolar RZ Line Code where Rb = ',num2str(Rb),' bits/sec']);
grid;
% --------------------------------------------------------
% For NRZ
A = sqrt(2);
R = [A^2/2 -(A^2)/4 0 0 0 0];
x = (pi*Tb)*f;
F = Tb*SA(x);
% Generating PSD of the NRZ Bipolar Line Code using (6-70a)
P = zeros(length(f),1);
for (i = 1:1:length(f))
P(i) = (abs(F(i)))^2/Tb;
temp = 0;
for (k = 2:1:length(R))
temp = temp + R(k)*cos(4*(k-1)*x(i));
end;
P(i) = P(i)*(R(1)+2*temp);
end;
Subplot(212)
plot(f,P);
xlabel('f in Hz -->');
ylabel('P(f)');
title(['PSD of Bipolar NRZ Line Code where Rb = ',num2str(Rb),' bits/sec']);
grid;
% --------------------------------------------------------