Danang University of Technology
LAB REPORT
Instructor : Mac Nhu Minh
Class : 14ECE
Group :4
Group members: Hoang Trung Thanh
Giao Huu Thuc
Thai Hoang Hung
Danang 2017 0
Contents
1. Lab 1. Elementary Music
Synthesis……………………………...02
2. Lab 2. Introduction of Image
Processing………………………...06
3. Lab 3. Linear
Convolution……………………………………….15
4. Lab 5. The DFT and Digital
Filtering……………………………22
5.
1
Lab 1: Elementary Music Synthesis
1. Music Synthesis
Code
Fs = 4000;
%Frequencies of the note
A = 220;
B = 220*2^(2/12);
C = 220*2^(3/12);
D = 220*2^(5/12);
E = 220*2^(7/12);
F = 220*2^(8/12);
G = 220*2^(10/12);
%List note
t1 = 0:1/Fs:1; %crotchet
t2 = 0:1/Fs:2; %minim
t4 = 0:1/Fs:4; %semibreve
P = zeros(1,200); %pause
A1 = sin(2*pi*A*t1);
A2 = sin(2*pi*A*t2);
A3 = sin(2*pi*A*t4);
B4 = sin(2*pi*B*t1);
C5 = sin(2*pi*C*t1);
E6 = sin(2*pi*E*t1);
%The required song:
y = [A2 P A1 P E6 P E6 P E6 P B4 P C5 P B4 P A3];
sound(y);
2. Volume Variations
We create a function called “NoteADSR” to generate a note with ADSR
function.
Code
function [out] = NoteADSR(t)
A = linspace(0, 1, length(t)/8);
D = linspace(1, 0.8, length(t)/8);
S = linspace(0.8, 0.8, length(t)/2);
R = linspace(0.8, 0, length(t)/4);
out = [A, D, S, R];
end
NoteADSR function
2
The new sound’s quality is improved when we multiply each
note with an ADSR function and it is also smoother the original
sound.
Code
Fs = 4000;
%List notes
A = 220;
B = 220*2^(2/12);
C = 220*2^(3/12);
D = 220*2^(5/12);
E = 220*2^(7/12);
F = 220*2^(8/12);
G = 220*2^(10/12);
t1 = 0:1/Fs:1-1/Fs;
t2 = 0:1/Fs:2-1/Fs;
t4 = 0:1/Fs:4-1/Fs;
A1 = sin(2*pi*A*t1);
A2 = sin(2*pi*A*t2);
A3 = sin(2*pi*A*t4);
B4 = sin(2*pi*B*t1);
C5 = sin(2*pi*C*t1);
E6 = sin(2*pi*E*t1);
%Create ASDR Note
ADSRt1 = NoteADSR(t1);
A1A = A1.*ADSRt1;
B1A = ADSRt1.*B4;
C1A = ADSRt1.*C5;
E1A = ADSRt1.*E6;
ADSRt2 = NoteADSR(t2);
A2A = ADSRt2.*A2;
ADSRt4 = NoteADSR(t4);
A3A = ADSRt4.*A3;
y = [ A2A A1A E1A E1A E1A B1A C1A B1A A3A ];
sound(y);
3. Tone Overlapping
We create a function called “overlap” which allow the decaying notes to overlap
slightly in time
Code
function [ note ] = overlap( noteA,noteB )
%overlap two notes, note A and note B from the input
interval = 800;
X = noteA (1 : length(noteA) - interval);
overlap = noteA(length(noteA) - interval + 1 : length(noteA))+
noteB(1 : interval);
Y = noteB(interval + 1 : length(noteB));
note = [X overlap Y];
3
end
Code
Fs = 4000;
A = 220;
B = 220*2^(2/12);
C = 220*2^(3/12);
E = 220*2^(7/12);
t1 = 0:1/Fs:1-1/Fs;
t2 = 0:1/Fs:2-1/Fs;
t4 = 0:1/Fs:4-1/Fs;
A1 = sin(2*pi*A*t1);
A2 = sin(2*pi*A*t2);
A3 = sin(2*pi*A*t4);
B1 = sin(2*pi*B*t1);
C1 = sin(2*pi*C*t1);
E1 = sin(2*pi*E*t1);
%Create ASDR Notes
ADSR1 = noteADSR(t1);
A1O = A1.*ADSR1;
ADSR2 = noteADSR(t2);
A2O = ADSR2.*A2;
ADSR4 = noteADSR(t4);
A3O = ADSR4.*A3;
B1O = ADSR1.*B1;
C1O = ADSR1.*C1;
E1O = ADSR1.*E1;
%Create overlapping tones
A21=overlap(A2O,A1O);
A1E=overlap(A1O,E1O);
EE=overlap(E1O,E1O);
EB=overlap(E1O,B1O);
BC=overlap(B1O,C1O);
CB=overlap(C1O,B1O);
BA3=overlap(B1O,A3O);
newsong=[A2 A21 A1E E1O EE E1O EE E1O EB B1O BC C1O CB B1O BA3 A3O A1O
A1E E1O EE E1O EE];
sound(newsong);
4
4. Favorite Music Synthesis
Code
Fs = 4000;
Bb = 220*2^(1/12);
C = 220*2^(3/12);
D = 220*2^(5/12);
E = 220*2^(7/12);
G = 220*2^(10/12);
AA = 440;
t1 = 0:1/Fs:1-1/Fs;
t2 = 0:1/Fs:2-1/Fs;
t4 = 0:1/Fs:4-1/Fs;
A2 = sin(2*pi*AA*t4);
B1 = sin(2*pi*Bb*t1);
C1 = sin(2*pi*C*t1);
D1 = sin(2*pi*D*t1);
E1 = sin(2*pi*E*t1);
G1 = sin(2*pi*G*t1);
%Create ASDR Notes
ADSR2 = noteADSR(t4);
A2O = ADSR2.*A2;
B1O = ADSR1.*B1;
C1O = ADSR1.*C1;
D1O = ADSR1.*D1;
E1O = ADSR1.*E1;
G1O = ADSR1.*G1;
P = zeros(1,1000);
%Create overlapping tones
EG=overlap(E1O,G1O);
A2E=overlap(A2O,E1O);
sym=[D10 EG E1O A2E E1O E1O D1O D1O E1O E1O P D1O E1O A2O G1O G1O E1O E1O
E1O D1O D1O P D1O D1O B1O D1O B1O D1O E1O A2O P D1O C1O D1O E1O A2O];
sound(sym);
5
Lab 2. Introduction to Image Processing
1. Edge Detection
Code
I = imread('DailyShow.jpg');
x = size(I);
figure, imshow(I); title('color image');
J = rgb2gray(I);
y = size(J);
figure, imshow(J); title('8-bit grayscale image');
h1 = [-1 0 1; -2 0 2; -1 0 1];
A = conv2(h1, J);
a = abs(A);
figure, imshow(a);
h2 = [1 2 1; 0 0 0; -1 -2 -1];
B = conv2(h2, J);
b = abs(B);
figure, imshow(b);
c = sqrt(a.^2 + b.^2);
figure, imshow(c);
Result:
6
For the other parts, we create some functions:
flip3.m
function [out]=flip3(a)
out=fliplr1(a);
out=flipud1(out);
end
7
extend.m
function [out]= extend(a)
sizep=size(a);
Ro=sizep(1)*2;
Co=sizep(2)*2;
a6=[];
for i=1:sizep(1)
a5=[];
for j=1:sizep(2)
a5=[a5 a(i,j) 0];
end
a6=[a6;a5;zeros(1,Co)];
end
for i=1:2:Ro-1
for j=2:2:Co-1
a6(i,j)=mean([a6(i,j-1) a6(i,j+1)]);
end
a6(i,Co)=a6(i,Co-1);
end
for j=1:Co
for i=2:2:Ro-2
a6(i,j)=mean([a6(i-1,j) a6(i+1,j)]);
end
a6(Ro,j)=a6(Ro-1,j);
end
out=a6;
end
fliplr1.m
function [out]=fliplr1(a)
sizep=size(a);
co=sizep(2);
a2=[];
for j=1:co
a2=[a2 a(:,co+1-j)];
end
out=a2;
end
flipud1.m
function [out]=flipud1(a)
sizep=size(a);
ro=sizep(1);
a2=[];
for i=1:ro
a2=[a2;a(ro+1-i,:)];
end
out=a2;
end
8
scale.m
function [out]=scale (s)
a = imread('DailyShow','jpg');
a = rgb2gray(a);
sizep=size(a);
a2=[];
for i=floor((s+1)/2):s:sizep(1)
a1=[];
for j=floor((s+1)/2):s:sizep(2)
a1 = [a1 a(i,j)];
end
a2=[a2;a1];
end
out=a2;
end
scale2.m
function [out]= scale2(s)
a = imread('DailyShow.jpg');
a = rgb2gray(a);
sizep=size(a);
a2=[];
for i=1:s:sizep(1)
a1=[];
for j=1:s:sizep(2)
a1=[a1 average(a,i,j,s)];
end
a2=[a2;a1];
end
out=uint8(a2);
end
average.m
function [out]=average(a,i,j,s)
sizep = size(a);
c = [];
for be=i:i+s-1
for en=j:j+s-1
if(en<=sizep(2) && be<=sizep(1))
c = [c a(be,en)];
end
end
end
out=round(mean(c));
end
9
2. Scaling
Normal scale with size 2
Advanced Scale with size 2
Normal scale with size 5
10
Advanced scale with size 5
>> d=scale2(2);
>> d=scale2(2);
>> imshow(d);
>> d=scale2(5);
>> imshow(d);
3. Image Flipping
Here is the result for flip
X[N-n+1, m] flip left to right
This is the result verified by Matlab’s command fliplr()
>> a=imread('DailyShow.jpg');
>> a=rgb2gray(a);
>> b=fliplr(a);
11
>> imshow(b)
The result from Matlab’s command flipup() is the same result
with the result from function fliplr1()
x[n, M-m+1] up to down
>> b=flipud(a);
>> imshow(b);
12
13
The result is the same as the figure from the function flipup1()
x[N-n+1, M-m+1] left to round and then round to left
14
This is the result of expand function
The size of original picture is <400x468 uint8> and the size of picture after
expanding is <800x936 uint8> . When we zoom in the two pictures, we see the
noise in the second one is less than that of the first one.
15
Lab 3. Linear Convolution
1. Matlab function “conv”
Code
x = [zeros(1,30) ones(1,20) zeros(1,50)];
h1 = [zeros(1,10) ones(1,10) zeros(1,80)];
h2 = [];
for i = 0:99
h2 = [h2 0.9^i];
end
h3 = [1 -1 zeros(1,98)];
y1 = conv(x,h1);
y2 = conv(x,h2);
y3 = conv(x,h3);
figure;
subplot(3,1,1);
stem(x);title('x(n) = u(n-30) – u(n-50)');
subplot(3,1,2);
stem(h1);title('h1(n) = u(n-10)– u(n-20)');
subplot(3,1,3);
stem(y1(1:100));title('y1(n) = x(n)*h1(n)');
figure;
subplot(3,1,1);
stem(x);title('x(n) = u(n-30) – u(n-50)');
subplot(3,1,2);
stem(h2);title('h2(n) = (0.9^n)u(n)');
subplot(3,1,3);
stem(y2(1:100));title('y2(n) = x(n)*h2(n)')
figure;
subplot(3,1,1);
stem(x);title('x(n) = u(n-30) – u(n-50)');
subplot(3,1,2);
stem(h3);title('h3(n) = delta(n) – delta(n-1)');
subplot(3,1,3);
stem(y3(1:100));title('y3(n) = x(n)*h3(n)')
16
Result:
17
2. Matrix-vector Multiplication to perform Linear
Convolution
Code
x = [1 2 3 4];
h = [3 2 1];
y = conv(x,h)
y = conv_tp(h,x)
The first column and the first row of H are depended on the
input signal and the transfer function h(n).
x = x'
x=
18
3
y = y'
y=
14
20
11
H = toeplitz([3,2,1,0,0,0],[3,0,0,0])
H=
3 0 0 0
2 3 0 0
1 2 3 0
0 1 2 3
0 0 1 2
0 0 0 1
We develop a function to implement linear convolution
Code
function [y,H] = conv_tp(h,x)
% Linear Convolution using Toeplitz Matrix
Nh = length(h);Nx = length(x);
Ny = Nx + Nh - 1;
col = [h zeros(1,Ny - Nh)]';
row = [h(1) zeros(1,Nx -1)];
H = toeplitz(col,row);
y = H*x';
19
end
3. Z-transform and Inverse Z-transform
Code
%using z-transform for x[n], we get the coefficients of factors in the
numerator and denominator of X(z)
bx = [0 0 0 0.25 -0.5 0.0625];
ax = [1 -1 0.75 -0.25 0.0625];
%using z-transform for h[n], we get the coefficients of factors in the
numerator and denominator of H(z)
bh = [0 -5];
ah = [3 -7 2];
%using convolution property of z-transform, we multiply the numerator and
denominator of X(Z) and H(Z) respectively, and get the result
by = [0 0 0 0 -5/4 5/2 -5/16];
ay = [3 -10 45/4 -8 55/16 -15/16 1/8];
[r,p,k] = residuez(by,ay);
%result
r =
-0.0030
6.0403 + 1.4014i
-1.7582 - 1.1420i
6.0403 - 1.4014i
-1.7582 + 1.1420i
-6.0612
p =
2.0000
0.2500 + 0.4330i
0.2500 + 0.4330i
0.2500 - 0.4330i
0.2500 - 0.4330i
0.3333
k =
-2.5000
%compute the first 10 samples of the sequence y[n]
%corresponding to Y(z) as below
delta = [1 0 0 0 0 0 0 0 0 0];
y = filter(by,ay,delta);
Result:
y =
Columns 1 through 7
0 0 0 0 -0.4167 -0.5556
-0.3935
Columns 8 through 10
-0.3395 -0.6600 -1.4700
20
21
4. Circular Convolution
Code
n = 0:1:99;
u10 = [zeros(1,10) ones(1,90)];
u20 = [zeros(1,20) ones(1,80)];
u0 = [ones(1,100)];
u30 = [zeros(1,30) ones(1,70)];
u50 = [zeros(1,50) ones(1,50)];
x = u30 - u50;
h1 = u10 - u20;
h2 = ((0.9).^n).*u0;
h3 = [1 -1 zeros(1,98)];
y1 = cir_conv(x,h1,100);
y2 = cir_conv(x,h2,100);
y3 = cir_conv(x,h3,100);
figure;
subplot(3,1,1); stem(x);
subplot(3,1,2); stem(h1);
subplot(3,1,3); stem(y1);
figure;
subplot(3,1,1); stem(x);
subplot(3,1,2); stem(h2);
subplot(3,1,3); stem(y2);
figure;
subplot(3,1,1); stem(x);
subplot(3,1,2); stem(h3);
subplot(3,1,3); stem(y3);
We use a function called “cir_conv” to do the same linear
convolutions in problem 1 using the circular convolution
Code
function [circularconv] = cir_conv(x,h, N)
xl = length(x);
hl = length(h);
x1 = [x zeros(1, N-xl)];
h1 = [h zeros(1, N-hl)];
X = fft(x1,N);
H = fft(h1,N);
Y = X.*H;
circularconv = ifft(Y);
end
22
Result:
23
Lab 5. The DFT and Digital Filtering
1. Matlab function “fft”.
Code
n = 0:127;
T = 10^-4; %sampling period
f1 = 0.25;
f2 = 0.5;
% in radians
phase = [0:127]*2/128;
s_phase = [-63:64]*2/128;%shifted phase
% in normalized frequency
freq1 = [0:127]*f1/128;
freq1s = [-63:64]*f1/128;
freq2 = [0:127]*f2/128;
freq2s = [-63:64]*f2/128;
% in Hertz
freq1h = [-63:64]*f1/T/128;
freq2h = [-63:64]*f2/T/128;
%signal
x1 = 1 + cos(2*pi*f1.*n);
x2 = 1 + cos(2*pi*f2.*n);
% work with signal x1
y1 = fft(x1);
y11 = fftshift(y1);
x12 = 1 + cos(2*pi*f1/T.*n);
y12 = fftshift(fft(x12));
% work with signal x1
y2 = fft(x2);
y21 = fftshift(y2);
x22 = 1 + cos(2*pi*f2/T.*n);
y22 = fftshift(fft(x22));
%plot for FFT(x1)
figure,
subplot(2,1,1);
stem(freq1,abs(y1));
title('The Magnitude of FFT(x1)');xlabel('Normalized Frequency');
subplot(2,1,2);
stem(phase,angle(y1));
title('The Phase of FFT(x1)');xlabel('w(*pi radians)');
%plot for shifted FFT(x1)
figure,
subplot(2,1,1);
stem(freq1s,abs(y11));axis tight;
title('The Magnitude of shifted FFT(x1)');xlabel('Normalized Frequency');
subplot(2,1,2);
stem(s_phase,angle(y11));
title('The Phase of shifted FFT(x1)');xlabel('w(*pi radians)');
24
%plot for shifted FFT(x1) in Hertz
figure,
subplot(2,1,1);
stem(freq1h,abs(y12));axis tight;
title('The Magnitude of shifted FFT(x1) in Hertz');xlabel('F(Hz)');
subplot(2,1,2);
stem(s_phase,angle(y12));
title('The Phase of shifted FFT(x1) in Hertz');xlabel('w(*pi radians)');
%plot for FFT(x2)
figure,
subplot(2,1,1);
stem(freq2,abs(y2));
title('The Magnitude of FFT(x2)');xlabel('Normalized Frequency');
subplot(2,1,2);
stem(phase,angle(y2));
title('The Phase of FFT(x2)');xlabel('w(*pi radians)');
%plot for shifted FFT(x2)
figure,
subplot(2,1,1);
stem(freq2s,abs(y21));axis tight;
title('The Magnitude of shifted FFT(x2)');xlabel('Normalized Frequency');
subplot(2,1,2);
stem(s_phase,angle(y21));
title('The Phase of shifted FFT(x2)');xlabel('w(*pi radians)');
%plot for shifted FFT(x2) in Hertz
figure,
subplot(2,1,1);
stem(freq2h,abs(y22));axis tight;
title('The Magnitude of shifted FFT(x2) in Hertz');xlabel('F(Hz)');
subplot(2,1,2);
stem(s_phase,angle(y22));
title('The Phase of shifted FFT(x2) in Hertz');xlabel('w(*pi radians)');
25
Result:
26
27
28
We have
x(n) = 1 + cos(2πfn), with f is the normalized frequency.
Use the table of DTFT, we get
δ(Ω−2 πf −2 πk )
[¿+ δ (Ω+ 2 πf −2 πk )]
X(Ω) = ∞ ∞
2π ∑ δ (Ω−2 πk )+ π ∑ ¿
k=−∞ k=−∞
From the above formula, it is the reason why the peak locations
of the FFT output appear.
After we execute the fftshift, the magnitude is symmetric to the
vertical axis, the phase of the output does not change.
With the sampling period T = 10-4, we find out the sampling
frequency Fs = 104
From the normalized frequency, we get the frequency in Hertz:
29
F = f.Fs
2. Frequency Shifting
Code
f1=0.15;
f2=0.2;
f3=0.4;
n= [0:255];
x1=sinc(f1.*(n-32));
x2=sinc(f1.*(n-32)).*(-1).^n;
x3=sinc(f1.*(n-32)).*cos(2*pi*f2*n);
x4= sinc(f3*(n-32)).*cos(2*pi*f3*n);
%radians
phase = [0:255]/256;
s_phase = [-127:128]/256;%shifted phase
%normalized frequency
freq1 = [0:255]*f1/256;
freq1s = [-127:128]*f1/256; %shifted freq1
freq2 = [0:255]*f2/256;
freq2s = [-127:128]*f2/256; %shifted freq2
freq3 = [0:255]*f3/256;
freq3s = [-127:128]*f3/256; %shifted freq3
freq4 = [0:255]*f3/256;
freq4s = [-127:128]*f3/256; %shifted freq4
%work with signal x1
y1 = fft(x1);
y11 = fftshift(y1);
x12 = sinc(f1.*(n-32));
y12 = fftshift(fft(x12));
%work with signal x2
y2 = fft(x2);
y21 = fftshift(y2);
x22 = sinc(f1.*(n-32)).*(-1).^n;
y22 = fftshift(fft(x22));
%work with signal x3
y3 = fft(x3);
y31 = fftshift(y2);
x32 = sinc(f1.*(n-32)).*cos(2*pi*f2*n);
y32 = fftshift(fft(x32));
%work with signal x4
y4 = fft(x4);
y41 = fftshift(y2);
x42 = sinc(f1.*(n-32));
y42 = fftshift(fft(x42));
%plot for FFT(x1)
figure,
subplot(2,1,1);
plot(freq1,abs(y1));
title('The Magnitude of FFT(x1)');xlabel('Normalized Frequency');
30
subplot(2,1,2);
plot(phase,angle(y1));
title('The Phase of FFT(x1)');xlabel('w(*pi radians)');
%plot for shifted FFT(x1)
figure,
subplot(2,1,1);
plot(freq1s,abs(y11));axis tight;
title('The Magnitude of shifted FFT(x1)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(s_phase,angle(y11));
title('The Phase of shifted FFT(x1)');xlabel('w(*pi radians)');
%plot for FFT(x2)
figure,
subplot(2,1,1);
plot(freq2,abs(y2));
title('The Magnitude of FFT(x2)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(phase,angle(y2));
title('The Phase of FFT(x2)');xlabel('w(*pi radians)');
%plot for shifted FFT(x2)
figure,
subplot(2,1,1);
plot(freq2s,abs(y21));axis tight;
title('The Magnitude of shifted FFT(x2)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(s_phase,angle(y21));
title('The Phase of shifted FFT(x2)');xlabel('w(*pi radians)');
%plot for FFT(x3)
figure,
subplot(2,1,1);
plot(freq3,abs(y3));
title('The Magnitude of FFT(x3)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(phase,angle(y3));
title('The Phase of FFT(x3)');xlabel('w(*pi radians)');
%plot for shifted FFT(x3)
figure,
subplot(2,1,1);
plot(freq3s,abs(y31));axis tight;
title('The Magnitude of shifted FFT(x3)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(s_phase,angle(y31));
title('The Phase of shifted FFT(x3)');xlabel('w(*pi radians)');
%plot for FFT(x4)
figure,
subplot(2,1,1);
plot(freq4,abs(y4));
title('The Magnitude of FFT(x4)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(phase,angle(y4));
title('The Phase of FFT(x4)');xlabel('w(*pi radians)');
%plot for shifted FFT(x4)
31
figure,
subplot(2,1,1);
plot(freq4s,abs(y41));axis tight;
title('The Magnitude of shifted FFT(x4)');xlabel('Normalized Frequency');
subplot(2,1,2);
plot(s_phase,angle(y41));
title('The Phase of shifted FFT(x4)');xlabel('w(*pi radians)');
32
Result:
33
34
35
36
3. FIR (Finite Impulse Response) Digital Filters
We create a low pass FIR filter
37
We export the coefficient for the use of
the frevalz function later. Based on the
given data, the coefficient of the
filter’s function is just numerator. Since
all poles are 0, the coefficient of
denominator is only 1. We, then,
export the numerator to the
workspace.
38
The coefficient:
Columns 1 through 6
-0.0337 -0.1353 -0.0003 0.1237 0.2840 0.3492
Columns 7 through 11
0.2840 0.1237 -0.0003 -0.1353 -0.0337
Turn on the frevalz plot of the system responses.
>> frevalz(Num,1,1)
ans =
0
0
0
0
0
0
0
0
0
0
39
Set the input signal of the filter be a pulse of length twenty
x[n] = u[n] – u[n – 20]
but its length be 60 (append 40 zeros in the end)
40
x = [ones(1,20) zeros(1,40)];
Use the “filter” function in MATLAB to implement the
FIR low pass filter
y = filter(Num,1,x);
stem(y);
xlabel('FIR low pass filter');
41
4.IIR (Infinite Impulse Response) Digital Filters
Use the MATLAB function “butter” to create a digital IIR low
pass Butterworth filter
[b,a] = butter(10,0.3,'low');
Turn on the frevalz plot of the system responses.
42
frevalz (b,a,1)
ans =
0.5218 + 0.7093i
0.5218 - 0.7093i
0.4299 + 0.5272i
0.4299 - 0.5272i
0.3739 + 0.3639i
0.3739 - 0.3639i
0.3416 + 0.2134i
0.3416 - 0.2134i
0.3267 + 0.0703i
0.3267 - 0.0703i
43
Use the MATLAB function “filter” to implement the IIR low pass
filter you’ve just produced with the same input in problem 3.
x = [ones(1,20) zeros(1,40)];
y = filter(b,a,x);
stem(y);
xlabel('IIR low pass Butterworth’s filter');
FIR filter: output seems to be flat in each different interval at
low frequencies and stop at the frequencies greater than 30.
IIR filter: output seems to fluctuate at low frequencies and still
fluctuate a little bit at the frequencies larger than 30.
44