-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem2.m
executable file
·110 lines (58 loc) · 1.15 KB
/
problem2.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
% problem 2
close all;
clear all;
syms t f
F = 4;
N = 64;
%declare x(t)
x = exp(-abs(t))/(1+abs(t))
delta_f = F/N;
delta_t = 1/F;
T = N*delta_t;
% periodize x(t)
ALIAS = 0;
for n =1:N
ALIAS = ALIAS + subs(x,t,t+n*T)+subs(x,t,t-n*T);
end
x_T = x + ALIAS;
%t_k = 0:N-1;
for k =0:N-1
xT(k+1) = subs(x_T,t,k*delta_t);
end
% Calculate X_F
xTk = zeros(1,N);
for n=1:N
xTk(n)= double(xT(n));
end
X_F = fft(T*xTk);
figure(1)
plot(fftshift(abs(X_F))); % need to tweak frequencies a little
title("X_F(f), F= 4 & N =64");
clear all;
syms t f
F = 8;
N = 256;
%declare x(t)
x = exp(-abs(t))/(1+abs(t))
delta_f = F/N;
delta_t = 1/F;
T = N*delta_t;
% periodize x(t)
ALIAS = 0;
for n =1:N
ALIAS = ALIAS + subs(x,t,t+n*T)+subs(x,t,t-n*T);
end
x_T = x + ALIAS;
%t_k = 0:N-1;
for k =0:N-1
xT(k+1) = subs(x_T,t,k*delta_t);
end
% Calculate X_F
xTk = zeros(1,N);
for n=1:N
xTk(n)= double(xT(n));
end
X_F = fft(T*xTk);
figure(2)
plot(fftshift(abs(X_F))); % need to tweak frequencies a little
title("X_F(f), F= 8 & N =256");