-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample2_05.m
More file actions
67 lines (46 loc) · 989 Bytes
/
Example2_05.m
File metadata and controls
67 lines (46 loc) · 989 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
60
61
62
63
64
65
66
67
% File: Example2_05.m for Example 2-5
% This example plots W(f) for a designated values of A, fo, and thets0
% The Magnitude-Phase Spectral Functions
% will be plotted.
% The Magnitude function will be plotted in dB units.
% The Phase function will be plotted in degree units.
clear;
thetao = 0;
% For this solution to this M file to be valid, fo is
% selected to be a positive integer less that 100.
fo = 40;
A = 30;
% Enter thetao in degree units
thetao = 20;
f = (-100):1:(100);
for k = 1:201
W(k) = 0;
if f(k)==fo;
W(k) = A/2;
end
if f(k)==-fo
W(k) = A/2;
end
end
for k = 1:201
theta(k) = 0;
if f(k)<0,
theta(k) = 90-thetao;
end
if f(k)>0,
theta(k) = -90+thetao;
end
end
B = log(W);
WdB = (20/log(10))*real(B);
subplot(211);
stem(f,WdB);
xlabel('f');
ylabel('W(f) in dB');
grid;
subplot(212);
plot(f,theta);
xlabel('f');
ylabel('Angle of W(f) in degrees');
grid;