You are on page 1of 43

EX: NO: 1

DATE: ADAPTIVE CHANNEL EQUALIZER

AIM:
To Design an Adaptive Channel Equalizer using MATLAB .

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB software version 7.4

THEORY:
Equalization is the reversal of distortion incurred by a signal transmitted through a channel.Equalizers are
used to render frequency response .Equalization is the process to remove
ISI and noise effects from the channel .Equalizers are of two types
1.Linear
2.Non linear
LINEAR EQUALIZERS :Aim at reducing ISI in linear channels using various algorithms like
least mean square,RLS and normalize LMS
NON LINEAR EQUALIZERS :Equalize non linear channels.They mainly use multilayer
perception (MLP).
LMS ALGORITHM:
• Introduced by window and hoff in 1959.
• Approximation of the steepest descent method.
• This algorithm is based on MMSE.
RLS ALGORITHM:
•Calculates the output signal y(n)of the adaptive filter.
• Update the filter coefficients vector.
The RLS is an adaptive filter which reversely find the coefficients that minimize linear least
squares cost function relating to the input signal.
Block Diagram:

PROCEDURE:
• Start the matlab and creats a new file .
• Edit program for channel equalization technique using MATLAB.
• Enter the program for equalizing signal vector .
• Enter equalizing technique with training sequence program and put the signal by
computing error rate.

RLS PROGRAM:
Clc;
Clear all;
Close all;
m=4;
n=2000;
random_int=randint(n,1,m);
qpsk_mod=pskmod(random_int,m);
sig_const=pskmod([0:m-1],m);
sample_len=500;
qpsk_mod_chanl=awgn(qpsk_mod,84,’measured’,1234);
chan=[.99;.88;.23,.12+.31i];
qpsk_mod_chan=filter(chan,1,qpsk_mod_chanl);
h=scatterplot(qpsk_mod_chan,1,sample_len,’bx’);
holdon
eq=lineareq(16,rls(.99,.1),sig_const);
[symbol,yd]=equalizer(eq,qpsk_mod_chan,qpsk_mod(1:sample_len));
Scatterplot(symbol,1,sample_len,’g’,h);
Scatterplot(qpsk_mod,1,0,’r*’,h);
holdoff
title(‘rlsequaliser constellation’);
legend(‘qpsk with channel’,’equalisedqpsk’,’ideal qpsk’);
qpsk_demod_ideal=pskdemod(qpsk_mod,m);
qpsk_demod_chan=pskdemod(qpsk_mod,chan,m);
qpsk_demod_equ=pskdemod(symbol,m);
error=length(find(qpsk_demod_ideal_random_int));
disp([‘no of bits’,num2str(n)]);
disp([‘bit error in ideal qpsk=’,num2str(error)]);
error=length(find(qpsk_demod_ideal_random_int));
disp([‘bit error for noisy qpsk=’,num2str(error)]);
error=length(find(qpsk_demod_equ_random_int));
disp([‘bit error for equalised qpsk=’,num2str(error)]);

LMS PROGRAM:
Clc;
Clear all;
Close all;
m=4;
n=2000;
random_int=randint(n,1,m);
qpsk_mod=pskmod(random_int,m);
sig_const=pskmod([0:m-1],m);
sample_len=500;
qpsk_mod_chanl=awgn(qpsk_mod,84,’measured’,1234);
chan=[.99;.88;.23,.12+.31i];
qpsk_mod_chan=filter(chan,1,qpsk_mod_chanl);
h=scatterplot(qpsk_mod_chan,1,sample_len,’bx’);
holdon
eq=lineareq(16,lms(.99,.1),sig_const);
[symbol,yd]=equalizer(eq,qpsk_mod_chan,qpsk_mod(1:sample_len));
Scatterplot(symbol,1,sample_len,’g’,h);
Scatterplot(qpsk_mod,1,0,’r*’,h);
holdoff
title(‘lmsequaliser constellation’);
legend(‘qpsk with channel’,’equalisedqpsk’,’ideal qpsk’);
qpsk_demod_ideal=pskdemod(qpsk_mod,m);
qpsk_demod_chan=pskdemod(qpsk_mod,chan,m);
qpsk_demod_equ=pskdemod(symbol,m);
error=length(find(qpsk_demod_ideal_random_int));
disp([‘no of bits’,num2str(n)]);
disp([‘bit error in ideal qpsk=’,num2str(error)]);
error=length(find(qpsk_demod_ideal_random_int));
disp([‘bit error for noisy qpsk=’,num2str(error)]);
error=length(find(qpsk_demod_equ_random_int));
disp([‘bit error for equalised qpsk=’,num2str(error)]);

RESULT:
Thus the matlab code to simulate Adaptive channel equalizers zero forcing Least mean
squares(LMS),Rescursive least squares(RLS) were written executed and verified successfully.
Output:
EX:NO:2 REALIZATION OF SUBBAND FILTER USING CONVOLUTION
DATE:

AIM:

1. Generation of impulse response of signals/systems.


2. Performing linear convolution of signals.
3. Performing circular convolution of signals.
4. Convolution of signals using overlap add and overlap and save method.
ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4

THEORY:
Convolution is a mathematical operation equivalent finite impulse response(FIR) Filtering.Convolution is important in
digital signal processing because convolution of two sequences in time domain convolution find application in processing
especially analyzing the output of the system x1(n),x2(n) the convolution of these two system is given by x3(n)=x1(n)*x2(n)

LINEAR CONVOLUTION:

The response (or) output y(n) of a LTI system for any arbitrary input is given by convolution of input x(n) and the
impulse response h(n) of the system.This means that if the impulse response of a system is known,then the response of the system
for any input can be determined by convolution operation.This convolution is also called aperiodic convolution.

CIRCULAR CONVOLUTION:

The convolution of two periodic sequences with periodicity N is called circular convolution.The DFT is used for the
analysis and design of discrete time system using digital computers.The DFT supports only circular convolution.Hence when DFT
techniques are employed,the results of linear convolution are obtained only via circular convolution.

OVERLAP SAVE METHOD:


In the overlap save method, the results of circular convolution of the various sections are obtained. In this method, the longer
sequence is divided into smaller sequences. Each section of the longer sequence and smaller sequence are converted to the size of
the output sequence of sectioned convolution. The circular convolution of the smaller sequence and each section of the longer
sequence is performed. The overall output sequence is obtained by combining the outputs
of the sectioned convolution.
Let,
N1=Length of the longer sequence
N2=Length of the smaller sequence
Let the longer sequence be divided into sections of size N3 (Normally N3= N2) In the overlap save method, the results of linear
convolution are obtained by circular convolution. Each section of the longer sequence and smaller sequence are converted to the
size of N3+N2-1 samples. The smaller sequence is converted to size of N3+N2-1 samples by
appending zeros. For the sections of longer sequence, the last N2-1 samples of a section are appended as last N2-1 samples of the
next section. In the output, the last N2-1 samples are discarded, and the remaining samples of the sectioned convolutions are saved
as the overall output sequence.

OVERLAP ADD METHOD

In the overlap add method, the longer sequence is divided into smaller sequences. The linear convolution of the smaller sequence
and each section of the longer sequence is performed. The overall output sequence is obtained by combining the outputs of
sectioned convolution.
Let,
N1=Length of the longer sequence
N2=Length of the smaller sequence
Let the longer sequence be divided into sections of size N3 (Normally N3= N2) The linear convolution of each section with smaller
sequence will produce output sequence of N3+N2-1 samples. In this method, the last N2-1 samples of each output sequence are
added with the first N2-1 samples of the next output sequence.
PROCEDURE:
• Generate one signals according to roll number. Say X1.
• Generate one signal X2 given in the list below:
• X2 = Exponential Signal
• X2 = Square signal
• X2 = Triangular signal
• X2 = Sinc function
• Find impulse response of X2. Denote it as h[n].
• Perform convolution operation and generate the third signal, y[n] = x1[n]*h[n].
• Repeat the above simulations for all the signals.
• Repeat all the above for Circular Convolution.
• Perform convolution using overlap add and overlap save method for any one signal

MATLAB CODE:
clc;
clear;

close all;

% Constants

roll_no = 101;
amp_1 = roll_no / 2;
amp_2 = amp_1 / 2;
sq_width = 25;
freq_1 = roll_no * 50;
freq_2 = roll_no / 5000;
sampling_freq_1 = freq_1 * 50;
sampling_period_1 = 1 / sampling_freq_1;
t_1 = 0:sampling_period_1:199 * sampling_period_1;
sampling_freq_2 = freq_2 * 500;
sampling_period_2 = 1 / sampling_freq_2;
t_2 = 0:sampling_period_2:199*sampling_period_2;
t_3 = -99 * sampling_period_2:sampling_period_2:100 * sampling_period_2;
% Signals
x_1 = amp_1 * sin(2*pi*freq_1*t_1);
x_2.exp = amp_2 * exp(t_2);
x_2.sq = repmat([ones(1, sq_width), zeros(1, sq_width)], 1, 200/(2 * sq_width));
for f = 1:length(t_3)
x_2.sinc(f) = sin(pi*t_3(f)) / pi * t_3(f);
end
x_2.tri = repmat([0:sq_width-1, sq_width:-1:1], 1, 200/(2 *sq_width));
% Plot Signals
fig1 = figure("Name", "X_1 Signals");
subplot(1, 1, 1);
stem(x_1, 'm'), legend("A=" +string(amp_1)+", f="+string(freq_1)+"Hz"),
xlabel("time"), ylabel("amplitude");
xlim([0, 100]);
title("Sinusoidal Signal x_1=A\cdotsin(2\pift)");
fig2 = figure("Name", "X_2 Signals");
subplot(4, 1, 1);
stem(x_2.exp, 'b'), legend("#=1, C=" +string(amp_2)), xlabel("time");
ylabel("amplitude");
xlim([0, 100]);
title("Exponential Signal x_2=C\cdote^{#t}");
subplot(4, 1, 2);
stem(x_2.sq, 'r'), legend("width=" +string(sq_width)),
xlabel("time");
ylabel("amplitude");
xlim([0, 100]);
title("Square Signal");
subplot(4, 1, 3);
stem(x_2.sinc, 'b'), legend("sinc"), xlabel("time");
ylabel("amplitude");
xlim([0, 100]);
title("Sinc Signal sinc(f)=sin(\pif)/(\pif)");
subplot(4, 1, 4);
stem(x_2.tri, 'r'), legend("width=" +string(sq_width)),
xlabel("time"), ylabel("amplitude");
xlim([0, 100]);
title("Triangular Signal");
% Linear Convolution of "x_1" with "x_2"s
conv_sin_exp = myconv(x_1, x_2.exp);
conv_sin_sq = myconv(x_1, x_2.sq);
conv_sin_sinc = myconv(x_1, x_2.sinc);
conv_sin_tri = myconv(x_1, x_2.tri);
fig3 = figure("Name", "Pairwise Linear Convolution Pt1");
subplot(2, 1, 1);
stem(conv_sin_exp, 'b'), xlabel("time"), ylabel("amplitude");
xlim([100 300]);
title("Conv(sin, exponential)");
subplot(2, 1, 2);
stem(conv_sin_sq, 'r'), xlabel("time"); ylabel("amplitude");
xlim([0 300]);
title("Conv(sin, square)");
fig4 = figure("Name", "Pairwise Linear Convolution Pt2");
subplot(2, 1, 1);
stem(conv_sin_sinc, 'b'), xlabel("time"); ylabel("amplitude");
xlim([0 300]);
title("Conv(sin, sinc)");
subplot(2, 1, 2);
stem(conv_sin_tri, 'r'), xlabel("time"); ylabel("amplitude");
xlim([0 300]);
title("Conv(sin, tri)");
% Circular Convolution of "x_1" with "x_2"s
cconv_sin_exp = cconv(x_1, x_2.exp);
cconv_sin_sq = cconv(x_1, x_2.sq);
cconv_sin_sinc = cconv(x_1, x_2.sinc);
cconv_sin_tri = cconv(x_1, x_2.tri);
fig5 = figure("Name", "Pairwise Circular Convolution Pt1");
subplot(2, 1, 1);
stem(cconv_sin_exp, 'b'), xlabel("time"), ylabel("amplitude");
xlim([100 300]);
title("Circular Conv(sin, exponential)");
subplot(2, 1, 2);
stem(cconv_sin_sq, 'r'), xlabel("time"); ylabel("amplitude");
xlim([0 300]);
title("Circular Conv(sin, square)");
fig6 = figure("Name", "Pairwise Circular Convolution Pt2");
subplot(2, 1, 1);
stem(cconv_sin_sinc, 'b'), xlabel("time"); ylabel("amplitude");
xlim([0 300]);
title("Circular Conv(sin, sinc)");
subplot(2, 1, 2);
stem(cconv_sin_tri, 'r'), xlabel("time"); ylabel("amplitude");
xlim([0 300]);
title("Circular Conv(sin, tri)");
% Overlap Add, Save of "x_1" with "x_2.exp"
ovradd_sin_exp = myoverlapadd(x_1, x_2.exp);
ovrsave_sin_exp = myoverlapsave(x_1, x_2.exp);
fig7 = figure("Name", "Overlap Methods");
subplot(2, 1, 1);
stem(ovradd_sin_exp, 'b'), xlabel("time"), ylabel("amplitude");
xlim([100 300]);
title("Overlap Add(sin, exponential)");
subplot(2, 1, 2);
stem(ovrsave_sin_exp, 'r'), xlabel("time"), ylabel("amplitude");
xlim([100 300]);
title("Overlap Save(sin, exponential)");
% Convolution Function
function output = myconv(x, y)
m = length(x);
n = length(y);
x = [x, zeros(1, n)];
y = [y, zeros(1, m)];
output = zeros(1, m+n-1);
for i = 1:m+n-1
for j = 1:m
if (i>=j)
output(i) = output(i) + x(j) * y(i-j+1);
end
end
end
end

% Circular Convolution Function


function output = mycconv(x, y)
m=length(x);
n=length(y);
N=max(m,n);
x=[x,zeros(1,N-m)];
y=[y,zeros(1,N-n)];
output=zeros(1,N);
for n=1:N
for i=1:N
j=n-i+1;
if(j<=0)
j=N+j;
end
output(n)=[output(n)+x(i)*y(j)];
end
end
end
% Overlap Save Function
function y = myoverlapsave(x, h)
L=200;
M=length(h);
lx=length(x);
r=rem(lx,L);
x1=[x zeros(1,L-r)];
nr=(length(x1))/L;
h1=[h zeros(1,L-1)];
for k=1:nr
Ma(k,:)=x1(((k-1)*L+1):k*L);
if k==1
Ma1(k,:)=[zeros(1,M-1) Ma(k,:)];
else
Ma1(k,:)=[Ma(k-1,(L-M+2):L) Ma(k,:)];
end
Ma2(k,:)=ifft(fft(Ma1(k,:)).*fft(h1));
end
Ma3=Ma2(:,M:(L+M-1));
y1=Ma3';
y=y1(:)';
end
% Overlap Add Function
function y = myoverlapadd(x, h)
M=length(h);
lx=length(x);
L=5;
r=rem(lx,L);
x1=[x zeros(1,L-r)];
nr=length(x1)/L;
h1=[h zeros(1,L-1)];
for k=1:nr
M1(k,:)=x1(((k-1)*L+1):k*L);
M2(k,:)=[M1(k,:) zeros(1,M-1)];
M3(k,:)=ifft(fft(M2(k,:)).*fft(h1));
M4(k,:)=[zeros(1,(k-1)*L) M3(k,:) zeros(1,(nr-k)*L)];
end
y=sum(M4);
end
OUTPUT

1. The signal X1 was generated


X1 is a sine wave generated. Total No. of samples=200

2.X2 was generated


1. Exponential Signal
2. Square Wave
3. Sinc function
4. Triangular Wave
3.X1 was convolved linearly with X2
a. Sine Wave convolved with Exponential Signal
b. Sine Wave convolved with Square wave

c.Sine wave convolved with sinc function

d.sine wave convolved with triangular wave


4.X1 was convolved circularly with X2

a.sine wave circularly convolved with exponential

b.sine wave circularly convolved with square wave


c.sine wave circularly convolved with sine

d.sine wave circularly convolved with Triangular wave

5.overlap add and overlap save method of convolution performed between sine and exponential signals
RESULT:

Thus the MATLAB program for Realization of subband filter using convolution was generated and their responses were
plotted in the time domain successfully.

EX: NO:3 REALIZATION OF STFT USING FFT

DATE:

AIM:

To write the MATLAB program for Realization of STFT using FFT.

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4

THEORY:

The Fast Fourier Transform (FFT) is a method (or algorithm) for computing the DFT with reduced number of calculations.
The computational efficiency is achieved if the adopt a divide and conquer approach. This approach is based on the decomposition
of an N-point DFT into successively smaller DFTs. This basic approach leads to a family of an efficient computational algorithm
known collectively as FFT algorithms.

In an N-point sequence, if N can be expressed as N=r m, then the sequence can be decimated into r-point sequences. For
each r-point sequence, r-point DFT can be computed. From the results of r-point DFT, the r 2-point DFTs, the r3-point DFTs are
computed and so on, until we get rm point DFT. In computing N–point DFT by this method of the number of stages of computation
will be m times. The number r is called the radix of the FFT algorithm.

For performing radix-2 FFT , the value of N should be such that, N=2 m. Here the decimation can be performed m times,
where m=log2N. In direct computation of N-point DFT , the total number of complex additions is N(N-1) and total number of
complex Multiplications are N2. In radix-2 FFT, the total number of complex additions is reduced to Nlog 2N and total number of
multiplications is reduced to (N/2) log2N.

SHORT TIME FOURIER TRANSFORM(STFT)

It is a fourier related transform used to determine the sinusoidal frequency and phase content of local sections of a

Signal as it changes over time.

PROGRAM:

clc;
close all;
clear all;
fs=1000;
t=0:1/fs:2;
y=sin(128*pi*t)+sin(256*pi*t);
%sine of periods 64 and 128
Level=6;
figure;
windowsize=128;
window=hanning(windowsize);
nfft=windowsize;
noverlap=windowsize-1;
[S,F,T]=spectrogram(y,window,noverlap,nfft,fs);
Imagesc(T,F,log10(abs(S)));
Set(gca,’YDir’,’Normal’);
Xlabel(‘Time(secs)’);
Ylabel(‘freq(Hz)’);
Title(‘short time fourier transform spectrum’);

OUTPUT
RESULT:
Thus the MATLAB program for Realization of STFT using FFT of a signal was written and output was
verified .
EX: NO: 4 DEMONSTRATION OF BAYES TECHNIQUE
DATE:

AIM:
To write the MATLAB program for the Demonstration of Bayes Technique .

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4

THEORY:
Bayesian analysis is a method of statistical inference that allows one to combine prior information about a population
parameter with evidence from information contained in a sample to guide the statistical inference process.
A prior probability distribution for a parameter of interest is specified first.The evidence is then obtained and combined through an
application of Bayes Theorem to provide a posterior probability distribution for the parameter.The posterior function provides the
basis for statistical inferences concerning the parameter.

PROGRAM:

function result = meanestimator(sigma0,u,sigma,n,X)


meanX = mean(X);
result = (n*meanX/sigma0)/((n/sigma0)+(1/sigma))+(u/sigma)/((n/sigma0)+(1/sigma));
endfunction
function result = varestimator(sigma0,sigma,n)
result = (sigma0*sigma)/((n*sigma)+sigma0);
endfunction
u = 50;
sigma = 100;
sigma0 = 60;
n =1;
X =40;
expec = meanestimator(sigma0,u,sigma,n,X);
var = varestimator(sigma0,sigma,n);
// d i s p ( e x p e c ) ;
// d i s p ( va r ) ;
zalpha = 1.645
lowerlim = -1*sqrt(var)*zalpha+expec;
upperlim = sqrt(var)*zalpha+expec;
disp(upperlim,"to",lowerlim,"With probability 0.9,the sent signal lies between",)
OUTPUT

Console
--> exec('C:\Users\Stelbiya\BE.sce', -1)
53.823527
"to"
33.676473
"With probability 0.9,the sent signal lies between

RESULT

Thus the Demonstration of Bayes Technique was implemented successfully.


EX: NO: 5 DEMONSTRATION OF MIN MAX TECHNIQUE

DATE:

AIM

To write a MATLAB program for Demonstration of Min Max Technique.

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4

PROGRAM

Maximum

clc;
clearall;
closeall;
t = linspace(-pi,pi);
plot(t,sin(t),'r-')
holdon
plot(t,cos(t),'b-');
plot(t,max(sin(t),cos(t)),'ko')
legend('sin(t)','cos(t)','max(sin(t),cos(t))','Location','NorthWest')

Minimum
clc;
clearall;
closeall;
t = linspace(-pi,pi);
plot(t,sin(t),'r-')
holdon
plot(t,cos(t),'b-');
plot(t,min(sin(t),cos(t)),'ko')
legend('sin(t)','cos(t)','min(sin(t),cos(t))','Location','NorthWest')
OUTPUT

1
sin(t)
0.8 cos(t)
max(sin(t),cos(t))
0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
-4 -3 -2 -1 0 1 2 3 4

1
sin(t)
0.8 cos(t)
min(sin(t),cos(t))
0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
-4 -3 -2 -1 0 1 2 3 4
1
sin(t)
0.8 cos(t)
min(sin(t),cos(t))
0.6

0.4

0.2

-0.2

-0.4

-0.6

-0.8

-1
-4 -3 -2 -1 0 1 2 3 4

RESULT
Thus the Demonstration of Min Max technique are obtained successfully using MATLAB and results were plotted.
EX: NO: 6 GENERATION OF MULTIVARIATE GAUSSIAN GENERATED DATA WITH DESIRED
MEAN VECTOR AND THE REQUIRED CO VARIANCE MATRIX

DATE:

AIM:

To write a MATLAB program for Calculate co variance matrix multivariate Gaussian distribution .

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4

PROGRAM:
clc ;
clear all;
clf();
//m = input ( ’ e n t e r mean v a l u e f o r Gaus s ian r . v . ’ )
// v a r i = input ( ’ e n t e r mean v a l u e f o r Gaus s ian r . v . ’ )
m = 2; //mean v a l u e o f g a u s s i a n data
sd = 1; // s t anda rd d e v i a t i o n
vari = sd ^2;
X = grand(100000,1,"nor",m,sd);
Xmax = max(X);
clf()
histplot(40,X,style =2)
x = linspace( -10,max(Xmax ),100)';
plot2d(x,(1/(sqrt(2*%pi*vari)))*exp(-0.5*(x-m).^2/vari),strf ="000",style =5)
xlabel('sample value');
ylabel('Gaussian output values');
title('Gaussian distributed data');
legend(["Gaussian random sample histogram" "exact density curve"],2);

RESULT

Thus the MATLAB program for calculate covariance matrix multivariate Gaussian distribution was written and output
was verified.
OUTPUT

EX:
NO:
7

REALIZATION OF THE ADAPTIVE FILTER USING LMS ALGORITHM (SOLVED USING DATE:
STEEPEST DESCENT ALGORITHM)

AIM:

To write a MATLAB program for Design an adaptive filter using steepest descent algorithm.

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4

PROGRAM:

set len of signal mp


mp=500
// set time vector n
n=(1:1:mp);
// set len of filter hmm and hmp
nfilter =20;
// set noise vector
R= .2 // variance Gaussian
av =0 // mean Gaussian
sd =sqrt(R) // std Gaussian
v = grand(1,mp,'nor',av,sd);// generate white gaussian
hmm = zeros(1,nfilter);
hmp = zeros(1,nfilter);
// est vector is dest
dest=zeros(1,mp);
// create input signal x in theta
dtheta =2*%pi/mp;
x=dtheta*n;
// create desired vector d as sin(x)
d =sin(x);
figure(0);
plot (x,d);
// set xmm init vector
i=1;
x1=x; // we are using x as d + noise so we store x as x1
// now create input vector x with noise
x= d+v;
deltn =.01 // step size
emm = zeros(1,nfilter);
emp= zeros(1,nfilter);
// begin computation for i statement
for i=1:mp-nfilter;
i;
xmm = x(1:1,i:(nfilter+i-1)) ;
in= i+1;
// set next input vector
//xmp = x(1:1, in: (nfilter+in -1) ) ;
// compute thedhat value from xmm ' *hmm
// dhat is set to zero vector first
dhat = xmm*hmm';
// update est vector
dest(i) = dhat;
// compute last error
elast= d(i)-dhat;
elast;
// update hmm vector
hmp= hmm+xmm*elast*deltn;
hmm =hmp;
// next step
end;
d;
dest;
figure(1);
subplot(221);
title ('true signal');
plot(x1,d);
subplot(222) ;
title ('signal+noise');
plot(x1,x);
subplot(224)
title ('filtered signal');
plot(x1,dest);
subplot(223)
title ('noise');
plot(x1,v);

RESULT

Thus the MATLAB program for Design of adptive filter using steepest descent algorithm was written and output was verified.

OUTPUT
EX: NO: 8 IMAGE COMPRESSION USING DISCRETE COSINE TRANSFORMATION(DCT)

DATE:

AIM:

To write a MATLAB program for Image compression using Discrete cosine Transformation(DCT).

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4
THEORY:

In the field of Image processing, the compression of images is an important step before we start the processing of larger images
or videos. The compression of images is carried out by an encoder and output a compressed form of an image. In the processes
of compression, the mathematical transforms play a vital role. A flow chart of the process of the compression of the image can
be represented as: 
Basic steps in image compression: 
Applying the image transform
Quantization of the levels
Encoding the sequences. 

Types of compression
1.Lossless: the compressed image can be converted back with zero error.
2.Lossy: the compressed image cannot be converted back to the original without error. The amount of error is inversely
proportional to the storage space (usually) and can be controlled by the user.

PROGRAM:

clc;
clear all;
close all;
I = imread('lena512.jpg');
figure, imshow(I);
% Y = I;
YCbCr = rgb2ycbcr(I);
figure, imshow(YCbCr);
Y = YCbCr(:,:, 1);
figure, imshow(Y);
[h, w] = size(Y);
r = h/8;
c = w/8;
s = 1;
q50 = [16 11 10 16 24 40 51 61;
12 12 14 19 26 58 60 55;
14 13 16 24 40 57 69 56;
14 17 22 29 51 87 80 62;
18 22 37 56 68 109 103 77;
24 35 55 64 81 104 113 92;
49 64 78 87 103 121 120 101;
72 92 95 98 112 100 103 99];

% COMPRESSION
for i=1:r
e = 1;
for j=1:c
block = Y(s:s+7,e:e+7);
cent = double(block) - 128;
for m=1:8
for n=1:8
if m == 1
u = 1/sqrt(8);
else
u = sqrt(2/8);
end
if n == 1
v = 1/sqrt(8);
else
v = sqrt(2/8);
end
comp = 0;
for x=1:8
for y=1:8
comp = comp + cent(x, y)*(cos((((2*(x-1))+1)*(m-1)*pi)/16))*(cos((((2*(y-1))+1)*(n-1)*pi)/16));
end
end
F(m, n) = v*u*comp;
end
end
for x=1:8
fory=1:8
cq(x, y) = round(F(x, y)/q50(x, y));

end
end
Q(s:s+7,e:e+7) = cq;
e = e + 8;
end
s = s + 8;
end

%%%%%%%%%%%%%%%
% % DECOMPRESSION
%%%%%%%
s = 1;
for i=1:r
e = 1;
for j=1:c
cq = Q(s:s+7,e:e+7);
for x=1:8
for y=1:8
DQ(x, y) = q50(x, y)*cq(x, y);
end
end
for m=1:8
for n=1:8
if m == 1
u = 1/sqrt(8);
else
u = sqrt(2/8);
end
if n == 1
v = 1/sqrt(8);
else
v = sqrt(2/8);
end
comp = 0;
for x=1:8
for y=1:8
comp = comp + u*v*DQ(x, y)*(cos((((2*(x-1))+1)*(m-1)*pi)/16))*(cos((((2*(y-1))+1)*(n-1)*pi)/16));
end
end

bf(m, n) = round(comp)+128;
end
end
Org(s:s+7,e:e+7) = bf;
e = e + 8;
end
s = s + 8;
end
imwrite(Y, 'F:\workouts\phd\jpeg\input.jpg');
imwrite(uint8(Org), 'F:\workouts\phd\jpeg\output.jpg');
return;

RESULT

Thus the MATLAB program for Image compression using Discrete cosine Transform(DCT) was written and output was verified.
OUTPUT:

Input Image

Ycomponent in YCbCr

OUTPUT IMAGE

EX: NO: 9 MULTIPLE INPUT MULTIPLE OUTPUT(MIMO)


DATE:

AIM:

To Simulate MIMO System using MATLAB .

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4
THEORY:
In radio multiple-input and multiple-output(MIMO) is a method for multiplying the capacity of a radio link
using multiple transmit and receive antennas to exploit multipath propagation. MIMO has become an essential
element of wireless communication standards including IEEE802.11n ( wifi ), IEEE802.11ac ( wifi ), 11SPAI(3G),
wiMAX (4G) and Long Term Evolution (4G).

MIMO cab be subdivided into three main categories: precoding, spatial multiplexing and diversity coding.
Precoding is multistream beam forming. In more general terms, it is considered to be all spatial processing that
occurs at the transmitter. In beam forming the same signal is emitted from each of the transmit antennas with
appropriate phase and gain weighting such that the signal power is maximized at the receiver input. Spatial
multiplexing requires MIMO antenna configuration.

In spatial multiplexing , a high-rate signal is split into multiple lower-rate stream and each stream is
transmitted from a different transmit antenna in the same frequency channel. Diversity coding techniques are used
when there is no channel knowledge at the transmitter. In diversity methods, a single stream is transmitted, but the
signal is coded using techniques called space-time coding.

PROGRAM:

MIMO SYSTEMS:

chan=mimochan(2,2,1e-4,60,[0 2.5e-4 3e-4],[0 -2 -3]);


chan.KFactor=2;
chan.TxCorrelationMatrix=[1 0.6;0.6 1];

chan.RxCorrelationMatrix=[10.5*j;-0.5*j1];
y=filter(chan,ones(20,2));
t=(0:19)*chan.InputSamplePeriod; plot(t,abs(y));
xlabel(‘Time’) ;
ylabel(‘Amp’);
legent(‘1st antenna output’,’2nd antenna output’);

PROCEDURE:

1. Open Matlab version R2014a.


2. Open new file and enter the program and save it.
3. Add the path to the location of the file in the system.
4. Compile the program and check for any error and debug it.
5. Note down the output.
OUTPUT

ChannelType:’MIMO’
NumTxAntennas: 2
NumRxAntennas: 2 InputSamplePeriod:
1.0000e-04 DopplerSpectrum: [1*1
doppler.jakes] MaxDopplerShift: 60
PathDelays: [0 2.5000e-04 3.0000e-04]

AvgPathGaindb: [0 -2 -3]
TxCorrelationMatrix: [2*2 double]
RxCorrelationMatrix: [2*2 double]

KFactor: 0

DirectPathDopplerShift: 0

DirectPathInitPhase: 0

ResetBeforeFiltering: 1

NormalizePathGains: 1

StorePathGains: 1 PathGains:
[4-D double]
ChannelFilterDelay: 4
NumSamplesProcessed: 0
RESULT:

Thus the matlab code to simulate MIMO system was written, executed and verified the output
successfully
EX: NO: 10 REALIZATION OF WIENER FILTER

DATE:

AIM:

To write a Matlab program for Realization of Wiener filter.

ESSENTIAL REQUIRED:

HARDWARE: Pc
SOFTWARE: MATLAB version 7.4
PROGRAM

Clc;
Clear all;
Close all;
Ioriginal=imread(‘cameraman.tif’);
Imshow(Ioriginal);
Title(‘original image’);
PSF=(fspecial(‘motion’,21,11);
IDouble=im2double(Ioriginal);
Blurred=imfilter(Idouble,psf,’conv’,’circular’);
Imshow(blurred);
Title(‘blurred image’);
Wnr1=deconvwnr(blurred,psf);
Imshow(wnr1);
Title(‘restored blurred image’);
Blurred_quantized=imfilter(Ioriginal,psf,conv.’circular’);
Imshow(blurred_quantized);
Title(‘blurred quantized image’);
Uniform_quantization_var=(1/256^2/12;
Signal_var=var(Idouble(:));
NSR=uniform_quantization_var/signal_var;
Wnr5=deconvwnr(blurred_quantized,psf,NSR);
Imshow(wnr5);
Title(‘reconstruction of Quantized image’);
OUTPUT
INPUT IMAGE
RESULT

Thus the matlab code for realization of Wiener filter was simulated successfully.
EX: NO:11 IMPLEMENTATION OF LMS FILTER USING TMS320C6X
DATE:

AIM:

To write an assembly language program for implementation of LMS filter using TMS320C6X Debugger.

COMPONENTS REQUIRED:

1. C50 Debugger software


2. DSP trainer kit
3. CRO
4.Function Generator
PROCEDURE:

 Connect the interface card ADI 2N to the TMS320C50 kit.


 View workspace workspace created.
 Project new project project name save the project.
 File New assembly file enter the program.
 Save the document.
 Add file to project and build the project.
Project add files to project
Serial port setting.
 Load the program to the kit
 Enter the two inputs.
 Output is noted.

PROGRAM:

* Cutoff frequency in KHz = 3.000000


.mmregs
.text
B START
CTABLE:
.word 0FFE7H ;Filter coefficients n=0
.word 0FFD3H
.word 0FFC6H
.word 0FFC4H
.word 0FFD0H
.word 0FFECH
.word 018H
.word 051H
.word 08CH
.word 0B9H
.word 0C2H
.word 092H
.word 01AH
.word 0FF5FH
.word 0FE78H
.word 0FD9AH
.word 0FD10H
.word 0FD30H
.word 0FE42H
.word 071H
.word 03B5H
.word 07CAH
.word 0C34H
.word 01054H
.word 01387H
.word 01547H
.word 01547H
.word 01387H
.word 01054H
.word 0C34H
.word 07CAH
.word 03B5H
.word 071H
.word 0FE42H
.word 0FD30H
.word 0FD10H
.word 0FD9AH
.word 0FE78H
.word 0FF5FH
.word 01AH
.word 092H
.word 0C2H
.word 0B9H
.word 08CH
.word 051H
.word 018H
.word 0FFECH
.word 0FFD0H
.word 0FFC4H
.word 0FFC6H
.word 0FFD3H
.word 0FFE7H ;Filter coefficients n=52

*
* Move the Filter coefficients
* from program memory to data memory
*
START:
MAR *,AR0 ;This block moves the filter coefficient from pgm memory to data
memory.
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
*
* Input data and perform convolution
*
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05
IN 0,06H
LAR AR7,#0
MAR *,AR7
BACK: BANZ BACK,*-
IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*- ;CONVOLUTION OPERATION
APAC
LAR AR1,#0300H
SACH *
LACC *
ADD #800h
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end

.word 0FEB9H

* Move the Filter coefficients


* from program memory to data memory

START:

MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF

* Input data and perform convolution

ISR: LDP #0AH


LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
IN 0,06H
LAR AR7,#0 ;change value to modify sampling freq.
MAR *,AR7

BACK: BANZ BACK,*-


IN 0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD 0FF00H,*-
APAC
LAR AR1,#0300H

SACH * ;give as sach *,1 incase of overflow


LACC *
ADD #800H
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end

RESULT

Thus an assembly language program was written for implementation of LMS Filter and the result was verified using
DSP trainer kit.

You might also like