Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

%Design of FIR Band Stop Filter with

Triangular Window
clear all
clc
fs=5000;
f1=2*1000/fs;
f2=2*2000/fs;
fn=[f1 f2];
n=30;
win=window(@triang, n+1);
subplot(221);
stem(win,r);
grid on;
xlabel(time);
ylabel(amp);
title(Triangular Window);
b=firl(n,fn,bandstop,win);
subplot(222);
stem(b,k);
grid on;
xlabel(time);
ylabel(amp);
title(Impulse Response);
[h om]=freqz(b);
subplot(223);
plot(om/(2*pi)*fs,20*log10(abs(h)),m);
grid on;

xlabel(frequency);
ylabel(mag);
title(Magnitude Response);
subplot(224);
plot(om/(2*pi)*fs,unwrap(angle(h))*57.3,b);
grid on;
xlabel(frquency);
ylabel(phase);
title(Phase Reasponse);

%Design of FIR Band Pass Filter with


Hanning Window
clear all
clc
fs=5000;
f1=2*1000/fs;
f2=2*2000/fs;
fn=[f1 f2];
n=88;
win=window(@hamming, n+1);
subplot(221);
stem(win,r);
grid on;
xlabel(time);
ylabel(amp);
title(Hamming Window);
b=firl(n,fn,bandpass,win);
subplot(222);
stem(b,k);
grid on;
xlabel(time);
ylabel(amp);

title(Impulse Response);
[h om]=freqz(b,1,512);
subplot(223);
plot(om/(2*pi)*fs,20*log10(abs(h)),m);
grid on;
xlabel(frequency);
ylabel(mag);
title(Magnitude Response);
subplot(224);
plot(om/(2*pi)*fs,unwrap(angle(h))*57.3,b);
grid on;
xlabel(frequency);
ylabel(phase);
title(Phase Response);

%Design of FIR High Pass Filter with


Hamming Window
clear all
clc
fs=2000;
fp=500;
fn=2*fp/fs;
n=30;
win=window(@hamming, n+1);
subplot(221);
stem(win,r);
grid on;
xlabel(time);
ylabel(amp);
title(Hamming Window);
b=firl(n,fn,highpass,win);
subplot(222);

stem(b,k);
grid on;
xlabel(time);
ylabel(amp);
title(Impulse Response);
[h om]=freqz(b);
subplot(223);
plot(om/(2*pi)*fs,20*log10(abs(h)),m);
grid on;
xlabel(frequency);
ylabel(mag);
title(Magnitude Response);
subplot(224);
plot(om/(2*pi)*fs,unwrap(angle(h))*57.3,b);
grid on;
xlabel(frequency);
ylabel(phase);
title(Phase Response);

%Design of FIR Low Pass Filter with


Flattop Window
clear all
clc
fs=4000;
fp=700;
fn=2*fp/fs;
n=30;
win=window(@flattopwin, n+1);
subplot(221);
stem(win,r);
grid on;
xlabel(time);

ylabel(amp);
title(Flattop Window);
b=firl(n,fn,lowpass,win);
subplot(222);
stem(b,k);
grid on;
xlabel(time);
ylabel(amp);
title(Impulse Response);
[h om]=freqz(b);
subplot(223);
plot(om/(2*pi)*fs,20*log10(abs(h)),m);
grid on;
xlabel(frequency);
ylabel(mag);
title(Magnitude Response);
subplot(224);
plot(om/(2*pi)*fs,unwrap(angle(h))*57.3,b);
grid on;
xlabel(frequency);
ylabel(phase);
title(Phase Response);

%Correlation of two functions


clc
clear
x=[1 2 3 2 7 8 4 6 9]
y=[3 8 5 9 2 3 8 7 8]
zx=xcorr(x,y)

subplot(211);
plot(zx);
grid on;
xlabel(Time(sec));
ylabel(Amplitude);
title(Cross Correlation);
za=xcorr(x,x)
subplot(212);
plot(zx);
grid on;
xlabel(Time(sec));
ylabel(Amplitude);
title(Auto Correlation);

%Convolution of two functions


clc
clear
A=[1 2 3 2 7 8 4 6 9]
B=[3 8 5 9 2 3 8 7 8]

C=conv(A,B);
subplot(311);
plot(A,r);
xlabel(Time(sec));
ylabel(Amplitude);
title(Signal-A);
subplot(312);
plot(A);
xlabel(Time(sec));
ylabel(Amplitude);
title(Signal-B);
subplot(313);
plot(A,m);
xlabel(Time(sec));
ylabel(Amplitude);
title(Convolution A & B);

%Generation of Sine signals with


different frequencies
clear
clc
freq=10;

samp_freq=100*freq;
t=0:(1/samp_freq):1;
x=sin(2*pi*freq*t);
subplot(311);
plot(t,x);
grid on;
xlabel(Time(sec));
ylabel(Amplitude);
title(Sine signal with Freq=10);
freq=50;
samp_freq=10*freq;
t=0:(1/samp_freq):1;
y=sin(2*pi*freq*t);
subplot(312);
plot(t,y);
grid on;
xlabel(Time(sec));
ylabel(Amplitude);
title(Sine signal with Freq=50);
freq=100;
samp_freq=10*freq;
t=0:(1/samp_freq):1;
z=sin(2*pi*freq*t);
subplot(313);
plot(t,z);
grid on;
xlabel(Time(sec));

ylabel(Amplitude);
title(Sine signal with Freq=100);

%Generation of Random Signal


clear
clc
t=0:0.01:10;
ran=rand(1,length(t));
plot(t,ran);
grid on;
xlabel(Time(sec));
ylabel(Amplitude);
title(Random Signal);

HDFC
4617
8653
0042
7096
4/16
K MANIKYALA RAO
412
PAVMANI11@

You might also like