INDEX
S.NO. DATE TOPIC PAGE SIGN
Basic Signals
1.
SECTION I
PRACTICAL NO 1
PROGRAM:
clc
clear all
close all
n=6; %Varible%
y3=cos(2*pi*t2);
subplot(2,1,2);plot(t2,y3);
ylabel('Amplitude---->');
xlabel('n---->');
title('Cose Sequence');
OUTPUT :
PRACTICAL NO 2
PROGRAM :
clc;
clear all;
close all;
%Frequency, Magnitude And Phase Response%
for n=1:1:257;
s(n)=3.5*sin(2*pi*(0.15)*n)+sin(2*pi*(0.4)*n)
end
x=1:257;
mag=abs(s(x));%To Calculate Magnitude%
subplot(2,1,1);plot(x,mag);
xlabel('n---->');
ylabel('Magnitude---->');
ag=phase(s(x));%To Calculate Phase%
subplot(2,1,2);stem(x,ag);
xlabel('n---->');
ylabel('Phase---->');
pause
for n=1:1:257;
s1(n)=3+5.657*cos(2*pi*(0.1)*n);
end
y=1:257;figure
mag1=abs(s1(y));
subplot(2,1,1);plot(y,mag1);
xlabel('n---->');
ylabel('Magnitude---->');
ag1=phase(s1(y));
subplot(2,1,2);plot(y,ag1);
xlabel('n---->');
ylabel('Phase---->');
OUTPUT :
PRACTICAL NO 3
PROGRAM :
clc
clear all
close all
OUTPUT :
PRACTICAL NO 4
PROGRAM :
clc
clear all
close all
OUTPUT :
PRACTICAL NO 5
PROGRAM :
OUTPUT :
PRACTICAL NO 6
PROGRAM :
clc
clear all
close all
OUTPUT :
PRACTICAL NO 7
PROGRAM :
clc
clear all
close all
N1=length(x);
N2=length(h);
N=max(N1,N2);
y=conv(x,h);
ly=length(y);
for i=1:1:N
if(N+i<=ly)
r(i)=y(i)+y(N+i);
else
r(i)=y(i);
end
end
OUTPUT :
PRACTICAL NO 8
PROGRAM:
clc
clear all
close all
%To Design Lowpass FIR Filter Using Rectangular, Hamming, Kaiser Windows%
sn = 0;
f=input('Enter The Sampling Frequency Where f = 0.8 or 0.6 or 0.4 or 0.2 := ');
n=input('Enter The Order Of Filter Where n = 16 or 32 or 64 or 128 or 256 := ');
disp('1 -- For Rectangular Window 2 -- For Hamming Window 3 -- For Kaiser
Window');
windowtype=input('Enter The Type Of Window: =');
for i=1:128
sn(i) = ((4*sin(2*pi*(f)*i)) + ((4/3)*sin(2*pi*3*(f)*i))+((4/5)*sin(2*pi*5*(f)*i))+
((4/7)*sin(2*pi*7*(f)*i)));
end
switch lower(windowtype)
case {1}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
ylabel('Magnitude (dB)')
title('Magnitude Response')
subplot(3,2,5);
plot(hs);grid;
xlabel('Filter using hamming window');
fvtool(b);
case{3}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
win = kaiser(n+1,2.5);
wn = 0.2 * pi; %Cutoff frequency
b = fir1(n,wn,win);
hs = filter(b,1,sn);
otherwise
disp('Not A Proper Window Type ');
end
OUTPUT:
RECTANGULAR WINDOW
HAMMING WINDOW
KAISER WINDOW
PRACTICAL NO 9
PROGRAM :
clc
clear all
close all
%To Design Highpass FIR Filter Using Blackman, Hanning, Kaiser Windows%
sn = 0;
f=input('Enter The Sampling Frequency Where f = 0.8 or 0.6 or 0.4 or 0.2 := ');
n=input('Enter The Order Of Filter Where n = 16 or 32 or 64 or 128 or 256 := ');
disp('1 -- For Blackman Window 2 -- For Hanning Window 3 -- For Kaiser
Window');
windowtype=input('Enter The Type Of Window: =');
for i=1:256
sn(i) = ((4*sin(2*pi*(f)*i)) + ((4/3)*sin(2*pi*3*(f)*i))+((4/5)*sin(2*pi*5*(f)*i))+
((4/7)*sin(2*pi*7*(f)*i)));
end
switch lower(windowtype)
case {1}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
%Creating FIR HP filter with Blackman window, returns the filter coefficients in
length N+1 vector B.
hs = filter(b,1,sn)%hs = filter(b,1,sn) %Input s(n) to the filter returns output hs
ylabel('Magnitude (dB)')
title('Magnitude Response')
case {2}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
subplot(3,2,5);
plot(b);grid;
xlabel('Filter using Hanning Window');
fvtool(b);
case{3}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
otherwise
disp('Not A Proper Window Type ');
end
OUTPUT:
BLACKMAN WINDOW
HANNING WINDOW
KAISER WINDOW
PRACTICAL NO 10
PROGRAM :
%To Design Lowpass And Highpass FIR Filter Using Rectangular Window%
clc
clear all
close all
sn = 0;
f=input('Enter The Sampling Frequency Where f = 0.8 or 0.6 or 0.4 or 0.2 := ');
n=input('Enter The Order Of Filter Where n = 16 or 32 or 64 or 128 or 256 := ');
disp('1 -- Lowpass Filter 2 -- For Highpass');
windowtype=input('Enter Your Choice : =');
for i=1:256
sn(i) = 3.5*(sin(2*pi*(0.15)*n)+sin(2*pi*(0.4)*n));
%sn(i) = (2*(cos(2*pi*(0.15)*n)+(sin(2*pi*(0.4)*n)));
%sn(i) = 3*exp(-0.1*n);
end
switch lower(windowtype)
case {1}
disp('1 -- For Rectangular Window 2 -- For Hamming Window 3 -- For Kaiser
Window');
windowtype=input('Enter The Type Of Window: =');
switch lower(windowtype)
case {1}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
%Create a filter and use sn as input
wn = 0.2 * pi; %Cutoff frequency
win=boxcar(n+1);%For Rectangular Window
b = fir1(n,wn,win); %Creating FIR LP filter with Rectangular window, returns
the filter coefficients in length N+1 vector B.
hs = filter(b,1,sn)%hs = filter(b,1,sn) %Input s(n) to the filter returns output hs
ylabel('Magnitude (dB)')
title('Magnitude Response')
case {2}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
case{3}
win = kaiser(n+1,2.5);
wn = 0.2 * pi; %Cutoff frequency
b = fir1(n,wn,win);
yn = filter(b,1,sn);
subplot(2,1,1);
plot(yn);grid
axis([0 100 -6 6]);
title('Output of the filter');
subplot(2,1,2);
plot(b);grid
xlabel('LP FIR using Kaiser Window ');
fvtool(b);
otherwise
disp('Not A Proper Window Type ');
end
case {2}
disp('1 -- For Blackman Window 2 -- For Hanning Window 3 -- For Kaiser
Window');
windowtype=input('Enter The Type Of Window: =');
switch lower(windowtype)
case{1}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
%Creating FIR HP filter with Blackman window, returns the filter coefficients
in length N+1 vector B.
hs = filter(b,1,sn)%hs = filter(b,1,sn) %Input s(n) to the filter returns output hs
% returns the frequency response vector H and the corresponding angular frequency
vector F
[H,F]=freqz(b,1,256);
plot(F,20 * log10(abs(H)));grid
xlabel('Normalized F (rad/sample)')
ylabel('Magnitude (dB)')
title('Magnitude Response')
case {2}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
case{3}
subplot(3,2,1);
plot(sn);grid;
axis([0 150 -10 10]);
otherwise
disp('Not A Proper Window Type ');
end
end
OUTPUT:
LOW PASS
HIGH PASS
SECTION II
PRACTICAL NO 11
PROGRAM :
clc
clear all
close all
subplot(2,1,1);
plot(om/pi,m);grid
xlabel('Normalised Frequency---->');
ylabel('Gain In dB---->');
title('Magnitude');
subplot(2,1,2);
plot(om/pi,an);grid
xlabel('Normalised Frequency---->');
ylabel('Phase In Radian---->');
title('Phase');
OUTPUT :
PRACTICAL NO 12
PROGRAM :
clc;
close all;
clear all;
subplot(2,1,2);
plot(om/pi,an);grid
xlabel('(b) Normalised frequency-->');
ylabel('phase in radian-->');
OUTPUT :
PRACTICAL NO 13
AIM :
PROGRAM :
clc
clear all
close all
% Radix 2 DIF-FFT%
N=input('Enter Length Of FFT : - ');
for i=1:N+1
if N==2^i
x=input('Input The Sequence');
z=fft(x,N);
y=bitrevorder(z);%To Shuffel The Output Sequence
disp('FFT Sequence');
disp(y);
subplot(2,1,1),stem(x);xlabel('n---->');ylabel('Amplitude----
>');title('Orignal Signal');
subplot(2,1,2),stem(z);xlabel('n---->');ylabel('Amplitude----
>');title('FFT Signal');
break
elseif N > 2^i
else
disp('Not a proper Number');
break
end
end
OUTPUT:
PRACTICAL NO 14
PROGRAM :
clc
clear all
close all
% Radix 2 DIT-FFT%
N=input('Enter Length Of FFT : - ');
for i=1:N+1
if N==2^i
x=input('Input The Sequence');
y=bitrevorder(x);%To Shuffel The Input Sequence
z=fft(x,N);
disp(y);
disp('FFT Sequence');
disp(z)
subplot(2,1,1),stem(x);xlabel('n---->');ylabel('Amplitude----
>');title('Orignal Signal');
subplot(2,1,2),stem(z);xlabel('n---->');ylabel('Amplitude----
>');title('FFT Signal');
break
elseif N > 2^i
else
disp('Not a proper Number');
break
end
end
OUTPUT:
PRACTICAL NO 15
PROGRAM :
clc
clear all
close all
Fs = 1024;
f=input('Enter The Value For Frequency f := ');
for n = 1:256
a(n) = cos(2*pi*f*n/Fs)+randn(size(n));
end
plot(a);
nfft = min(256,length(a)) ;
fs= 1024;
specgram(a,nfft,fs);%
OUTPUT:
PRACTICAL NO 16
PROGRAM :
clc
clear all
close all
n=17;
f=[0 0.3 0.4 0.6 0.7 1];
a=[0 0 1 1 0 0];
b=remez(n,f,a);
[h,w] = freqz(b,1,512);
plot(f,a,w/pi,abs(h))
legend('Ideal','remez Design');
OUTPUT :
PRACTICAL NO 17
PROGRAM :
clc
clear all
close all
%X = [1 2 ; 3 4];
%H = [5 6 ; 7 8];
y = conv2(x,h);
plot (y);
OUTPUT :
PRACTICAL NO 18 DATE: / /
PROGRAM :
clc
clear all
close all
switch lower(seq)
case{1}
%One-Dimensioinal Cross-Correlation And Auto-Correlation%
x=input('Enter the first One Dimensional Sequence : ');
h=input('Enter the Second One Dimensional Sequence : ');
case{2}
otherwise
disp('Select a correct option.');
end
OUTPUT :
PRACTICAL NO 19
PROGRAM :
clc
clear all
close all
%Stability Check%
b=input('Enter the denominator coefficients of the filter : ');
k=poly2rc(b);%divides The second coefficient by First Coefficient
knew=fliplr(k);%To Flip The Matrix
s=all(abs(knew));%True if all elements of a vector are nonzero
if(s==1)
disp('Stable System');
else
disp('Non Stable System');
end
OUTPUT:
PRACTICAL NO 20
PROGRAM :
clc
clear all
close all
OUTPUT:
X=123 becomes 3 2 1
456 654