clc; clear all;close all;
format short
T = input('enter the symbol interval T');
br= input('enter the bit rate value br');
rf= input('enter the roll off factor rf');
n = [-10 10];
y = 5000*rcosfir(rf,n,br,T);
ds = [5 2 5 2 5 2 5 2 5 5 5 5 2 2 2 5 5 5 5];
m = length(ds);
n1 = length(y);
i = 1;
z = conv(ds(i),y);
while(i)
z = conv(ds(i+1),y);
z1 = [z,zeros(1,1.75*br)];
z2= [zeros(1,1*1.7*br),z];
z = z1 + z2;
i = i+1;
end
%plot(z);
h =randn(l,length(ds));
rs1 = filer(h,1,z);
for i = 1;
length(ds);
rs(i) = rs1(i)/15;
end
for i = 1:round(x3/3),
rs(i) = randn(1);
end
fs = [5 5 2 2 2 2 2 5 2 2 2 5 5 5 2 5 2 5 2];
m = length(ds);
n1 = length(y);
i = 1;
z = conv(fs(i),y);
while(i)
z = conv(fs(i+1),y);
z1 = [z, zeros(1,1.75*br)];
z2 = [zeros(1,i*1.75*br),z];
z = z1 + z2;
i = i+1;
end
fs1 = rs+fs;
ar = xcorr(ds,ds);
crd = xcorr(rs,ds);
l1 = length(ar);
j = 1;
for i = round(l1/2):l1,
ar1(j)=ar(i);
j = j+1;
end
r = toeplitz(ar1);
l2 = length(crd);
j = 1;
for i = round(l1/2):l2,
crd1(j) = crd(i);
j = j+1;
end
p = crd1;
lam = max(eig(r));
la = min(eig(r));
l = lam/la;
w = inv(r)*p;
e = rs - filter(w,1,ds);
s = 1; mu = 1.5/lam;
ni = 1;
while(sle_10)
w1 = w-2*mu*(e.*ds);
rs
y4 = filter(w1,1,ds);
e = y4-rs;
s = 0; e1 = xcorr(e);
for i = 1:length(e1);
s = s/length(e1);
if(y4 == rs)
break
end
ni = ni + 1;
w = w1;
end
end
figure(1);
subplot(2,2,1);
plot(z);
title('near end signal');
subplot(2,2,2);
plot(rs);
title('echo produced in the hybrid');
subplot(2,2,3);
plot(fs);
title('desired signal');
subplot(2,2,4);
plot(fs1);
title('echo added with desired signal');
figure(2);
subplot(2,1,1);
plot(y4);
title('estimated echo signal using LMS algorithm');
subplot(2,1,2);
plot(fs1-y4);
title('echo cancelled signal');