-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem_3.m
130 lines (88 loc) · 1.95 KB
/
problem_3.m
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
%% Final Problem 3
%{
let x(t) = sinc^2(pi*t)
then by Lecture 1 triangular pulse example and the symmetry property H(t) <=> h(-f), X(f) = 1-abs(f), abs(f)<1; and 0 elsewhere. Therefore, the Nyquist frequency fc=1.
%}
%%
clear all;
close all;
syms t
x = (sin(pi*t)/(pi*t))^2
figure()
ezplot(x, [-2 2 -.5 1])
legend('x(t)')
N=12;
%% part(a)
F=3;
sum_pos=0;
for k =1:N
sum_pos = sum_pos+subs(x,t,k/F)*sinc(F*(t-k/F));
end
DC=limit(x,t,0)*sinc(F*t); % verify sinc(0) = 1; k =0 value;
sum_neg = 0;
for k=1:N
sum_neg = sum_neg+subs(x,t,-k/F)*sinc(F*(t+k/F));
end
y_a=sum_neg+DC+sum_pos;
%% part(b)
F=2;
sum_pos=0;
for k =1:N
sum_pos = sum_pos+subs(x,t,k/F)*sinc(F*(t-k/F));
end
DC=limit(x,t,0)*sinc(F*t); % verify sinc(0) = 1; k =0 value;
sum_neg = 0;
for k=1:N
sum_neg = sum_neg+subs(x,t,-k/F)*sinc(F*(t+k/F));
end
y_b=sum_neg+DC+sum_pos;
%% part(c)
F=1;
sum_pos=0;
for k =1:N
sum_pos = sum_pos+subs(x,t,k/F)*sinc(F*(t-k/F));
end
DC=limit(x,t,0)*sinc(F*t); % verify sinc(0) = 1; k =0 value;
sum_neg = 0;
for k=1:N
sum_neg = sum_neg+subs(x,t,-k/F)*sinc(F*(t+k/F));
end
y_c=sum_neg+DC+sum_pos;
%% plot part(a)
figure()
ezplot(x, [-2 2 -.5 1])
legend("x(t)")
hold on
ezplot(y_a, [-2 2 -.5 1])
legend("y_a(t)")
title("x(t) and y_a(t)")
hold off
legend('x(t)', 'y_a(t)')
figure()
ezplot(x-y_a, [-2 2 -.5 1])
title("x(t)-y_a(t)")
%% plot part (b)
figure()
ezplot(x, [-2 2 -.5 1])
hold on
ezplot(y_b, [-2 2 -.5 1])
title("x(t) and y_b(t)")
hold off
legend('x(t)', 'y_b(t)')
figure()
ezplot(x-y_b, [-2 2 -.5 1])
title("x(t)-y_b(t)")
%% plot part(c)
figure()
ezplot(x, [-2 2 -.5 1])
hold on
ezplot(y_c, [-2 2 -.5 1])
title("x(t) and y_c(t)")
hold off
legend('x(t)', 'y_c(t)')
%{
For F values F=2 & F=3, y(y) is indistinguishable from x(n);
%}
figure()
ezplot(x-y_c, [-2 2 -.5 1])
title("x(t)-y_c(t)")