Mean Square Error Estimation of A Signal: Part B: Matlab or Labview Experiments

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Part B: Matlab or Labview Experiments:

1.

Mean Square Error estimation of a signal

2.

Implementation of LMS algorithm

3.

Time delay estimation using correlation function

4.

Study of eye diagram of PAM transmission system

5.

Generation of QAM signal and constellation graph

1. Mean Square Error estimation of a signal


clc;
clear all;
N=100;
%Input signal
f=1000;
t=0:0.00001:0.001;
X_Tra= 10*sin(2*pi*f*t);
% Adding White Gaussian noise by the channel
SNR=0.01;
X_Noise=AWGN(X_Tra,SNR);
% plot(X_Noise);
X_Rec=X_Noise;
%Cost = (Received signal - Estimated signal).^2
Error_UnCor = sum((X_Rec - X_Tra).^2)/N;
X_Fil= filter([0.33 0.33 0.33],1,X_Rec);
% plot(X_Fil);
Error_Cor=sum((X_Fil - X_Tra).^2)/N;
figure;
subplot(311);
plot(X_Tra);
subplot(312);
plot(X_Rec);
subplot(313);
plot(X_Fil);

2. Implementation of LMS algorithm


clc;
clear all;
sysorder = input('Enter the System Order? ');
N = input('Enter the number of Itterations? ');
x = randn(N,1); % Input to the filter
b = fir1(sysorder-1,0.5); % FIR system to be identified
n = 0.1*randn(N,1); % Uncorrelated noise signal
d = filter(b,1,x)+n; % Desired signal = output of H + Uncorrelated noise signal
w = zeros (sysorder, 1); % Initially filter weights are zero
for n = sysorder : N
u = x(n:-1:n-sysorder+1);
y(n)= w' * u; % output of the adaptive filter
e(n) = d(n) - y(n); % error signal = desired signal - adaptive filter output
mu=0.008;
w = w + mu * u * e(n); % filter weights update
end
hold on
plot(d,'g')
%plot(y,'r');
semilogy((abs(e)),'m');
title('System output') ;
xlabel('Samples')
ylabel('True and estimated output')
legend('Desired','Output','Error')
axis([0 N -2 2.5])
figure
plot(b', 'k+')
hold on
plot(w, 'r*')
legend('Actual weights','Estimated weights')
title('Comparison of the actual weights and the estimated weights') ;

3. Time delay estimation using correlation function


Clc
N=1:257;
x = [5 5 5 5 5 zeros(1,252)];
a=0.7;
xd = [zeros(1,32) a*x(1:225)];
subplot(231)
plot(N,x)
title('Original signal x')
subplot(232)
plot(N,xd)
title('Delayed signal xd')
y=xcorr(x,xd)
subplot(233)
y1=y(1:length(N))
y2=fliplr(y1);
plot(N,y2)
title('Figure showing peak at point of time delay')
%after adding noise
w=randn(1,length(N));
attn = 1;
r=xd+attn*w;
y=xcorr(x,r);
subplot(234)
plot(N,x)
title('Original signal x')
subplot(235)
plot(N,r)
title('Received signal with noise added r')
subplot(236)
y1=y(1:length(N))
y2=fliplr(y1);
plot(N,y2)
title('Figure showing peak at point of time delay')

4. Study of eye diagram of PAM transmission system


clear all;
Fs=20;
Fd=1;
Pd=500;
M=input('Enter the value of M');
%x=input('Enter the sequence');
x=randint(Pd,1,M);
a=length(x);

%Generate the PAM signal


for k=1:a
for t=0:(M-1)
if (x(k) == t)
y(k) = -[(M-1)-2*t];
end
end
end

alpha=0.0;
msg_a= y+ alpha*y.^2;

rcv_a=rcosflt(msg_a,Fd,Fs);
N = Fs/Fd;
eyediagram(rcv_a,N);

5. Generation of QAM signal and constellation graph


clc;
clear all;
close all;
x=input('Enter the input sequence');
m=input('Enter the value of m');
k=1;
l=sqrt(m);
for i=-(l-1):2:l-1
for j=l-1:-2:-(l-1)
a(k)=i;
b(k)=j;
k=k+1;
end;
end;
l=length(x);
i=sqrt(-1);
for j=1:l
y(j)=a(x(j)+1)+i*b(x(j)+1);
end
Scatterplot(y);

You might also like