-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem7.m
45 lines (34 loc) · 1 KB
/
problem7.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
clear all;
close all;
clc
%Before running code! Plase, dowload the x4fun.mat in our github. If you
%cant find it, then go to Canvas under the projecy folder in EE23
%Conclusion: Incrementing the eigen value, reduces the noise. However, the
%bigger the eigen value, the lower the Amplitude of the signal.
load('x4fun.mat')
N_SAMP = 1024;
N = 11;
w = linspace(0, 2 * pi * (1 - 1 / N_SAMP), N_SAMP);
w = transpose(w);
h_n = zeros(N_SAMP, 1);
h_n(1 : 11) = 1/N;
%PArt1, a)
y_n = conv(x, h_n);
Y_jw = fft(y_n, N_SAMP);
H_jw = fft(h_n, N_SAMP);
% Replace H_jw_inv with Wiener filter!
eigen = linspace(0, 50, 6);
noise_n = 0.01 * randn(N_SAMP, 1);
noise_jw = fft(noise_n);
Y_jw_noise = Y_jw + noise_jw;
M = 2;
% Try multiple values of eigen
for j = 1 : length(eigen)
G_w_jw = abs((1-exp(1i.*w)).^M);
H_w_jw = conj(H_jw) ./ ((abs(H_jw).^2) + (eigen(j)*(abs(G_w_jw)).^2));
X_jw = Y_jw_noise .* H_w_jw;
x_d2 = ifft(X_jw,N_SAMP);
figure(j)
plot(w,x_d2);
title(['\lambda = ', num2str(eigen(j))])
end