-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem3.m
executable file
·61 lines (43 loc) · 982 Bytes
/
problem3.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
clear all;
close all;
clc;
T=2*pi;
f_o=1/T;
syms t f
S_N = 0;
for m=1:40
S_N = S_N+1/m*cos(m*t);
end
figure(1)
ezplot(S_N, [0 T])
title("S_N(t)")
%{
for m=1:40
S_N = S_N+1/m*cos(m*t);
end
figure(2)
ezplot(S_N, [0 T]) %looks reversed -- need to fix that. it has to be somewhere with calculating coefficients
title
%}
Sigma_N = 0;
for m=1:40
Sigma_N = Sigma_N+(40-abs(m))/40*(1/m)*cos(m*t);
end
figure(2)
ezplot(Sigma_N, [0 T])
title("Sigma_N(t)")
%% estimate the function
figure(3)
box = heaviside(t)-heaviside(t-T);
x = box/sin(t/2)-2.7;
ezplot(x, [0 T])
title("x(t)")
%%
% periodize x(t)
x_T = x + subs(x,t, t-T) + subs(x,t,t+T) + subs(x,t, t-2*T) + subs(x,t,t+2*T);
%% calculate x_hat of the function
syms l
A = 2/T*int(x_T*cos(2*pi*l*t/T), t, -T/2 , T/2);
B = 2/T*int(x_T*sin(2*pi*l*t/T), t, -T/2 , T/2);
% show they are the same as series coefficients which I already got for N =
% 40