100% found this document useful (1 vote)
645 views2 pages

FIR Filter Design MATLAB Code

This document contains code to design and analyze four different types of filters: low-pass, high-pass, band-pass, and band-stop. It calculates the filter coefficients, computes the frequency response, and plots the magnitude response of each filter on a separate subplot of a 2x2 grid.

Uploaded by

Koushik Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
645 views2 pages

FIR Filter Design MATLAB Code

This document contains code to design and analyze four different types of filters: low-pass, high-pass, band-pass, and band-stop. It calculates the filter coefficients, computes the frequency response, and plots the magnitude response of each filter on a separate subplot of a 2x2 grid.

Uploaded by

Koushik Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

clc; %% BAND-PASS FILTER

clear all;
close all; wn= [wp ws];
b = fir1(n, wn, y);
rp = 0.04; [h,o] = freqz(b,1,256);
rs = 0.05; m = 20*log10(abs(h));
fp = 1500; subplot(2,2,3);
fs = 2000; plot (o/pi,m);
f = 9000; ylabel('gain in db-->');
xlabel(' (c) normalised frequency--
wp=2*fp/f; >');
ws=2*fs/f; title ('BAND-PASS FILTER');

num = -20*log10(sqrt(rp*rs)) -13; %% BAND-STOP FILTER


dem = 14.6*(fs-fp)/f;
b = fir1(n, wn, 'STOP', y);
n = ceil(num/dem); [h, o] = freqz(b,1,256);
n1=n+1; m=20*log10(abs(h));
if (rem(n, 2)~=0) subplot (2,2,4);
n1=n; plot (o/pi,m);
n=n-1; ylabel('gain in db-->');
end xlabel(' (d) normalised frequency--
>');
y=hamming(n1); title('BAND-STOP FILTER');

%% LOW-PASS FILTER

b = fir1(n, wp, y);


[h,o] = freqz(b,1,256);
m=20*log10(abs(h));
subplot (2,2,1);
plot (o/pi,m);
ylabel('gain in db-->');
xlabel(' (a) normalised frequency--
>');
title('LOW-PASS FILTER');

%% HIGH-PASS FILTER

b = fir1(n, wp, 'HIGH',y);


[h,o] = freqz(b,1,256);

m = 20*log10(abs(h));
subplot (2,2,2);

plot (o/pi,m);
ylabel('gain in db-->');
xlabel(' (b) normalised frequency--
>');
title('HIGH-PASS FILTER');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy