-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample2_11.m
More file actions
53 lines (33 loc) · 741 Bytes
/
Example2_11.m
File metadata and controls
53 lines (33 loc) · 741 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
% File: Example2_11.m for Example 2-11 and Eq (2-72)
% This example plots PSD, Pw(f), for a designated
% values of A and fo
% The Power Spectral Density will be plotted.
% The PSD will be plotted in dB units.
clear;
% For this solution to this M file to be valid, fo is
% selected to be a positive integer less that 100.
fo = 40;
A = 5;
f = (-100):10:(100);
for k = 1:length(f)
PSD(k) = 0;
if f(k)==fo;
PSD(k) = (A^2)/4;
end
if f(k)==-fo
PSD(k) = (A^2)/4;
end
end
B = log(PSD);
PSDdB = (10/log(10))*real(B);
subplot(211);
stem(f,PSD);
xlabel('f in Hz -->');
ylabel('PSD(f)');
grid;
subplot(212);
stem(f,PSDdB);
xlabel('f in Hz -->');
ylabel('PSDdB(f) in dB');
grid;