Question

# Problem 3 you can use Matlab and also i give u the Problem 1 code its...

Problem 3 you can use Matlab and also i give u the Problem 1 code its on Matlab

Using the same initial code fragment as in Problem 1, add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR bandpass filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce

this is the Problem 1 code and the solutin

clear; clc;
Fs = 8000;
Nbits = 16;
tMax = 10;
N = Fs*tMax+1;
f = linspace(0.0,0.2,N);
x = zeros(size(f));
plot(f,x)
phi = 0;
for n=0:N-1 x(n+1) = 0.8*sin(phi);
phi = phi+2*pi*f(n+1);
end
sound(x,Fs,Nbits);
pause % this will pause the programm after sounding the first.
% sleep(10000);

% creating the low pass butterwidth filter
Fn = 800; % cut off frequency
n = 4; % order of the filter
[b,a] = butter(n,Fn/(Fs/2))
% b = zeros, a = poles of the TF
TF = tf(b,a);
imp_res = impulse(TF);
y_n = conv(imp_res,x);
y_n = y_n(1:length(f));
% Ploting the Y(n) with frequency
plot(f,y_n);
grid on
xlabel('frequency')
ylabel('y(n)')
title('frequency responce')
% Playing Y(n)
sound(y_n,Fs,Nbits);
% the output from the input and filter coefficients
y = filter(b,a,x)

% end program  