0% found this document useful (0 votes)
48 views1 page

Matlab Code - : %Q4 %length of Impulse Response

The document contains MATLAB code to design and analyze low-pass filters. The first section of code (Q4) designs a rectangular window-based low-pass filter with a cutoff frequency of 1000 Hz and sampling frequency of 5000 Hz. It calculates the filter coefficients and plots the magnitude and phase response using freqz. The second section of code (Q5) designs a Hamming window-based type 3 low-pass filter with a length of 21 taps. It calculates the impulse response, filters coefficients, and plots the amplitude response between 0 and pi radians.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views1 page

Matlab Code - : %Q4 %length of Impulse Response

The document contains MATLAB code to design and analyze low-pass filters. The first section of code (Q4) designs a rectangular window-based low-pass filter with a cutoff frequency of 1000 Hz and sampling frequency of 5000 Hz. It calculates the filter coefficients and plots the magnitude and phase response using freqz. The second section of code (Q5) designs a Hamming window-based type 3 low-pass filter with a length of 21 taps. It calculates the impulse response, filters coefficients, and plots the amplitude response between 0 and pi radians.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

4.

MATLAB CODE ----


%Q4

N=17; %Length of Impulse Response


L=N+1;

Wc=1000; %Cutoff Frequency


Ws=5000; %Sampling Frequency
Wn=Wc/Ws; %Normalized frequency

b=fir1(L,Wn,'low'); %Rectangular Window based LPF design


freqz(b); % Magnitude and phase Plot using freqz

MATLAB CODE –
%Q5

N=21; % Hamming Window Length


alpha=(N-1)/2;
n = 0:N-1;
hd = (cos(pi*(n-alpha)))./(n-alpha); % Impulse Response of digital
Filter
hd(alpha+1)=0;

k=(hamming(N))';
h=hd.*k; %Type 3 LP impulse response

L=(N-1)/2; %L = Order of Hr
c=2*h(L+1:-1:1); %c = Type-3 LP filter coefficients
n=0:1:L;
w=(0:1:100)'*pi/100; %frequencies between [0 pi] over which Hr is
computed
Hr = sin(w*n)*c'; %Hr = Amplitude Response
plot(w/pi,Hr/pi);

You might also like