Question

# Problem 1 ...... you can use Matlan i got one so all what i need is...

Problem 1 ...... you can use Matlan i got one so all what i need is 2, 3 and 4 one of them or all of them .. thanks

The following Scilab code generates a 10-second “chirp” with discrete frequencies ranging from 0 to 0.2 with a sampling frequency of 8 kHz.

clear; Fs = 8000;

Nbits = 16;

tMax = 10;

N = Fs*tMax+1;

f = linspace(0.0,0.2,N);

x = zeros(f);

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);

sleep(10000); //allows full sound to play Add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR lowpass filter with cutoff frequency 800 Hz and based on a 4th order Butterworth prototype. You should also generate a plot of y (n) vs. frequency (plot(f,y);). Name your program p1.sce Calculate the output from the input and filter coefficients using the following command: y = filter(b,a,x);

Problem 2

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 highpass filter with cutoff frequency 800 Hz and based on a 4th order Butterworth prototype. Name your program p2.sce

Problem 3

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

Problem 4

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 bandstop filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce

I Have solved all questions except 3.

MATLAB code is given below in bold letters.

clear all ;close all;
Fs = 8000;

Nbits = 16;

tMax = 10;

N = Fs*tMax+1;

f = linspace(0.0,0.2,N);

x = zeros(f);

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);

% sleep(10000);

% Low pass filter

[b,a] = butter(4,Wn);

y = filter(b,a,x);

sound(y,Fs,Nbits);

figure;plot(f,y);title('f vs y for low pass')

% High pass filter
clear Wn a b y;

[b,a] = butter(4,Wn,'high');

y = filter(b,a,x);

sound(y,Fs,Nbits);

figure;plot(f,y);title('f vs y for High pass');

% Band stop filter
clear Wn a b y;
Wn = [750 850]/8000; % rad/sample

[b,a] = butter(4,Wn,'stop');

y = filter(b,a,x);

sound(y,Fs,Nbits);

figure;plot(f,y);title('f vs y for Band stop');    #### Earn Coins

Coins can be redeemed for fabulous gifts.