Question

Discrete Time Signal Processing Question 1. Consider an IIR filter A(1-2-1 cos ω0) 1-2cos ω02-1+2 I. Compute its impulse resp

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%BUTTERFILTFILT Design and apply Butterworth filter.

%

% INPUTS

% ------

% x - Data to be filtered.

% Filter operates on first non-singleton dimension.

%

% fc - Cutoffs frequencies (one frequency value for types 'lowpass'

% and 'highpass' and two frequency values for types 'bandpass'

% and 'bandstop').

%

% fs - Data sampling frequency.

%

% order - Order of the Butterworth filter (default: order = 6)

%

% type - Filtering type option. Can be either 'lowpass', 'highpass',

% 'bandpass' or 'bandstop'.

%

% direction - Direction to filter in

% 'forward' | 'backward' | {'both'}

% NB: if this is 'both' the output has zero phase filtering,

% and order must be an even number.

%

% NB: If a bandpass is requested with filter bounds [0 F], a lowpass

% filter is performed instead. If a bandpass is requested with filter

% upper bound Inf or the Nyquist freq, a highpass filter is performed.

%  

%

% OUTPUTS

% -------

% x - Filtered data

%

% A - Filter coefficient matrix (denominator)

%

% B - Filter coefficient matrix (numerator)

function [x, A, B] = butterfiltfilt(x, fc, fs, order, type, direction)

% DEFAULT INPUTS ----------------------------------------------------------

if nargin<6 || isempty(direction)

direction = 'both';

end

if nargin<5 || isempty(type)

type = 'bandpass';

end

if nargin<4 || isempty(order)

order = 6;

end

if nargin<3 || isempty(fc)

if all(fc>=0) && all(fc<=1)

fs = 1;

else

error('Sampling frequency not given');

end

end

% INPUT HANDLING ----------------------------------------------------------

if nargin<2; error('Insufficient number of inputs'); end

if ~isnumeric(x); error('Data must be numeric'); end;

if ~isnumeric(fc); error('Filter bounds must be numeric'); end

if ~isnumeric(fs) || ~isscalar(fs); error('Sampling frequency must be a scalar'); end

if ~isnumeric(order) || ~isscalar(order); error('Order must be a scalar'); end

if ~ischar(type); error('Type must be a string'); end

if ~ischar(direction); error('Direction must be a string'); end

% MAIN --------------------------------------------------------------------

% If bidirectional filter, halve the order as filter is done twice

if strcmp(direction,'both')

if mod(order,2)~=0;

error('Filter order must be even if filter is bidirectional');

end

order = order/2;

end

% Change type to lowercase

type = lower(type);

% Move to band notation

switch type

% Lowpass

case {'low','lowpass'}

if numel(fc)~=1; error('Too many bounds given'); end;

fc = [0 fc];

  

% Highpass

case {'high','highpass'}

if numel(fc)~=1; error('Too many bounds given'); end;

fc = [fc Inf];

  

% Bandpass

case {'band','bandpass'}

% Do nothing

  

% Bandstop

case {'bandstop','stop'}

type = 'stop'; % Cannonical

  

otherwise

error('Type %s not found',type);

  

end

% Make bounds be relative to Nyquist frequency

fc = fc*2/fs;

% Design the filter -------------------------------------------------------

if numel(fc)~=2

error('Filter requires two cutoff frequencies');

  

elseif strcmp(type,'stop')

% Do bandstop filter

[B,A] = butter(order, fc, 'stop');

% If not bandstop, must be bandpass.

  

elseif (fc(1)==0) && (isinf(fc(2)))

% No filter required

B = NaN;

A = NaN;

return;

  

elseif fc(1)==0

% Lower bound is 0: design lowpass filter

[B,A] = butter(order, fc(2), 'low');

  

elseif isinf(fc(2)) || fc(2)==1

% Upper bound is Inf or Nyquist freq: design highpass filter

[B,A] = butter(order, fc(1), 'high');

  

else

[B,A] = butter(order, fc);

  

end

  

% Use the filter ----------------------------------------------------------

switch direction

case 'forward'

x = FilterM(B, A, x);

case 'backward'

x = FilterM(B, A, x, [], 'reverse');

case 'both'

if ispc

x = filter(B, A, x);

x(end:-1:1,:) = filter(B, A, x(end:-1:1,:));

else

x = FiltFiltM(B, A, x);

end

otherwise

error('Unrecognised filter direction: %s',direction);

end

end

I hope u can understand this. ..

Add a comment
Know the answer?
Add Answer to:
Discrete Time Signal Processing Question 1. Consider an IIR filter A(1-2-1 cos ω0) 1-2cos ω02-1+2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using filterDesigner in MATLAB, design a second order low pass IIR Butterworth filter whose sampling frequency (Fs) is 1...

    Using filterDesigner in MATLAB, design a second order low pass IIR Butterworth filter whose sampling frequency (Fs) is 1 kHz and cutoff frequency (Fc) is 10 Hz. Find the numerator and denominator coefficients. Write its transfer function H(z) = Y(z) / X(z). Write its difference function y(k). Draw (copy from Filter Designer) the magnitude response plot. Draw (copy from Filter Designer) the phase response plot. Draw (copy from Filter Designer) the impulse response plot.

  • Using filterDesigner in MATLAB, design a second order low pass IIR Butterworth filter whose sampling frequency...

    Using filterDesigner in MATLAB, design a second order low pass IIR Butterworth filter whose sampling frequency (Fs) is 1 kHz and cutoff frequency (Fc) is 10 Hz. Find the numerator and denominator coefficients. Write its transfer function H(z) = Y(z) / X(z). Write its difference function y(k). Draw (copy from Filter Designer) the magnitude response plot. Draw (copy from Filter Designer) the phase response plot. Draw (copy from Filter Designer) the impulse response plot.

  • 1. By using an analog filter with a Butterworth response of order 3, design a digital IIR low pass filter with 3-db cutoff frequency 2c 0.6TT a) b) c) Evaluate the transfer function of the analog fil...

    1. By using an analog filter with a Butterworth response of order 3, design a digital IIR low pass filter with 3-db cutoff frequency 2c 0.6TT a) b) c) Evaluate the transfer function of the analog filter (10marks) Skecth the block diagram of transfer function (5 marks) Plot the magnitude response of the filters. (5marks) 1. By using an analog filter with a Butterworth response of order 3, design a digital IIR low pass filter with 3-db cutoff frequency 2c...

  • Design lowpass IIR filter with the following specifications: Filter order = 2, Butterworth type C...

    Design lowpass IIR filter with the following specifications: Filter order = 2, Butterworth type Cut-off frequency=800 Hz Sampling rate =8000 Hz Design using the bilinear z-transform design method Print the lowpass IIR filter coefficients and plot the frequency responses using MATLAB. MATLAB>>freqz(bLP,aLP,512,8000); axis([0 4000 –40 1]); Label and print your graph. What is the filter gain at the cut-off frequency 800 Hz? What are the filter gains for the stopband at 2000 Hz and the passband at 50 Hz based...

  • kindly solve this question... digital signal processing...... Question #1: a) An IIR lc w pass filter...

    kindly solve this question... digital signal processing...... Question #1: a) An IIR lc w pass filter is designed with the Butterworth n CCLO 43 C14 method ej 1 Q2 1+0 provides the following pole plot with N-2 and Q = 0.56, S, = Oe'2 zero N Img Re 1 0-395903 Question #1: a) An IIR lc w pass filter is designed with the Butterworth n CCLO 43 C14 method ej 1 Q2 1+0 provides the following pole plot with N-2...

  • 1. Consider a signal of the form (t) = 2 cos(100nt) cos(1507) This signal is first...

    1. Consider a signal of the form (t) = 2 cos(100nt) cos(1507) This signal is first sampled at the rate of 80 samples per second and the result was processed with an ideal reconstruction filter, again assuming that sampling rate was 80 samples per second. What is the signal that results after the reconstruction? Show enough details in your answer to demonstrate that you understand the theory of sampling and reconstruction from samples. Hint: Write (t) as a sum of...

  • 1. A continuous-time signal x(t) is obtained at the output of an ideal lowpass filter with...

    1. A continuous-time signal x(t) is obtained at the output of an ideal lowpass filter with cutoff frequency wc = 10007. If impulse-train sampling is performed on x(t), which of the following sampling periods would guarantee that y(t) can be recovered from its sampled version using an appropriate lowpass filter? (a) T=0.5x10-3 (b) T=2x10-3 (c) T=10-4

  • 1.The filter coefficients of a second-order digital IIR filter are: a0 = 1, a1 = -2,...

    1.The filter coefficients of a second-order digital IIR filter are: a0 = 1, a1 = -2, a2 = 2, b0 = 1, b1 = 1/2, b2 = 1/8. (a's are numerator coefficents and b's are the denominator coefficients). Compute the magnitude response |H(ejω)| where ω = 5.174 rad/sec. 2. It is desired to extract a constant signal s(n)= s from the noisy measured signal x(n)= s(n)+v(n)= s + v(n), where v(n) is zero-mean white Gaussian noise of variance ϭv2. For...

  • Problem 1 A sinusodial signal x(t)- sin2t (t in seconds) is input to a system with frequency resp...

    Problem 1 A sinusodial signal x(t)- sin2t (t in seconds) is input to a system with frequency response: H(G What signal y(t) is observed at the output? Problem 2 The inverse Fourier transform of a system frequency response is given by h(t)t. The signal x(t) 3 cos(4t 0.5) is input to the system (t in seconds). (a) What is the expression of the signal y(t) at the system output? (b) What is the power attenuation in dB caused by the...

  • A linear time invariant system has an impulse response given by h[n] = 2(-0.5)" u[n] –...

    A linear time invariant system has an impulse response given by h[n] = 2(-0.5)" u[n] – 3(0.5)2º u[n] where u[n] is the unit step function. a) Find the z-domain transfer function H(2). b) Draw pole-zero plot of the system and indicate the region of convergence. c) is the system stable? Explain. d) is the system causal? Explain. e) Find the unit step response s[n] of the system, that is, the response to the unit step input. f) Provide a linear...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT