Experiments Using Matlab
Experiments Using Matlab
1.
2.
3.
4.
subplot(3,1,3);
stem(nz,z);
xlabel('Time');ylabel('Amplitude');
title('Circular Convolution');
5.
6.
7.
8.
Computation of N point DFT of a given sequence and to plot magnitude and phase
spectrum.
clc;clear all;close all;
x=input('Enter x[n]:');
nx=0:length(x)-1;
N=32;
%Compute DFT
n=0:length(x)-1;
for k=0:N-1
w=exp(-j*2*pi*k*n/N);
dot_prod=x.*w;
X(k+1)=sum(dot_prod);
end
%Plot the input
subplot(3,1,1);
stem(nx,x);
xlabel('Time');ylabel('Input x[n]');
title('Input sequence x[n]
');
title('Computation of DFT ');
%Plot the magnitude spectrum
subplot(3,1,2);
stem(abs(X));
xlabel('Time');ylabel('Amplitude');
title('Magnitude Spectrum');
%Plot the phase spectrum
subplot(3,1,3);
stem(angle(X));
xlabel('Time');ylabel('Angle in radian');
title('Phase Spectrum');
9.
stem(lh,h);
xlabel('Time');ylabel('Amplitude');
title('Impulse Response h[n]');
subplot(3,1,3);
stem(nz,z);
xlabel('Time');ylabel('Amplitude');
title('Linear Convolution ');
%Verification
z1=conv(xnew,hnew)
10.
11.
den=14.6*(fs-fp)/f;
n=ceil(num/den);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
y=boxcar(n1);
%-----> (1)
b=fir1(n,wp,'low',y);
%-----> (2)
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);plot(o/pi,m);
title('Magnitude response');
xlabel('Normalised frequency');
ylabel('Gain in dB');
subplot(2,1,2);plot(o/pi,an);
title('Phase response');
xlabel('Normalised frequency');
ylabel('Gain in rad');
%make relevent changes in (1) for diff. window
%
%
%
%
%
%
boxcar------->rectangular window
bartlett----->bartlett window
blackman----->blackman window
chebwin------>chebyshev window
hamming------>hamming window
hanning------>hanning window
12.
beta=5.8
%butterworth filter
clc;close all;clear all;
format long;
rp=input('Enter the passband ripple:');
rs=input('Enter the stoopband ripple:');
fp=input('Enter the passband frequency:');
fs=input('Enter the stoopband frequency:');
f=input('Enter the sampling frequency:');
wp=2*fp/f;
ws=2*fs/f;
[n,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(n,wn,'low');
w=0:0.01:pi;
[h,o]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);plot(o/pi,m);
title('Magnitude response');
xlabel('Normalised frequency');
ylabel('Gain in dB');
subplot(2,1,2);plot(o/pi,an);
title('Phase response');
xlabel('Normalised frequency');
ylabel('Gain in rad');
%--------->(1)
%--------->(2)
rs=35
fp=1500
fs=2000
f=8000
2.
3.
4.
Realization of an FIR filter (any type) to meet given specifications .The input can be a
signal from function generator / speech signal.
5.
Audio applications such as to plot time and frequency (Spectrum) display of Microphone
output plus a cosine using DSP. Read a wav file and match with their respective spectrograms
6.
Noise: Add noise above 3 kHz and then remove; Interference suppression using 400 Hz
tone.
7.