-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject_DSP_Pt1.m
57 lines (43 loc) · 1.17 KB
/
Project_DSP_Pt1.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
%{
PROJECT 1 DSP
Group Members:
Ahmad Faaiz (1721421)
Eiman Salleh (1728753)
%}
% Part 1: DISCRETE SYSTEM - MOVING AVERAGE FILTER
%% a) 24-point Moving Average Filter
%{
Remove the comment bracket for part a)
load bostemp
days = (1:31*24)/24;
figure(1)
plot(days,tempC);
title('Original Signal')
axis tight
avg_point = 24;
coeff24hMA = ones(1, avg_point)/avg_point;
avg24_TempC = filter(coeff24hMA, 1, tempC);
fDelay = (length(coeff24hMA)-1)/2;
figure(2)
plot(days,[tempC avg24_TempC]);
title('24-point Filtered Signal with Delay')
axis tight
figure(3)
plot(days,tempC,days-fDelay/24,avg24_TempC);
title('24-point Filtered Signal No Delay')
axis tight
%}
%% b) 50-point Moving Average Filter using convolution
load bostemp
days = (1:31*24)/24;
plot(days, tempC);
hold on
title('50-point Moving Average Filter')
point = 50;
Amp_point = ones(1, point)/point;
y_axis_data = tempC'; % transpose 'tempC' from [744 1] to get [1 744]
k = conv(y_axis_data,Amp_point); % size(k) = [1 793] which is not the same length with original data
w = conv(y_axis_data,Amp_point,'same'); %'same' is used to ensure the length of the convolution is the same as original data
plot(days,w)
axis tight
hold off