Adaptive Algorithms i need a matlab code for itSolution1 Pro

Adaptive Algorithms

i need a matlab code for it

Solution

1) %Program to illustrate adaptive filtering using the LMS algorithms:

% X delayed input data vector

% Y measured signal

% W coefficient vector

% E enhanced signal

N=30; % filter length

M=0; % delay

w0=1; % initial value for adaptive filter coefficients

SF=2048; % factor for reducing the data samples - 11 bit ADC assumed

mu=0.04;

X = zeros(N,1);

delay = zeros(1,M+1);

W = w0*ones(N,1);

in = fopen(\'ADF.dat\',\'r\'); %read input data from specified data file

Y = fscanf(in,\'%g\',inf)/SF;

fclose(in);

if w0==0

sf = SF; % scaling factor for display

else

sf = SF/N/w0;

end

for i=1:length(Y)

if M>0

delay(2:M+1) = delay(1:M); % shift data for delay

end

delay(1) = Y(i);

X(2:N) = X(1:N-1); % update buffer

X(1) = delay(M+1);

E(i) = Y(i)-W\'*X; % the enhanced signal

W = W + 2*mu*E(i)*X; % update the weights

end

subplot(2,1,1),plot(1:length(Y),Y*SF); title(\'Input Signal\');

subplot(2,1,2),plot(1:length(E),E*sf); title(\'Enhanced Signal\');

2) % program to illustrate adaptive filtering using the RLS algorithm via the UDU factorization:

% X delayed input data vector

% Y measured signal

% W coefficient vector

% E enhanced signal

clear all;

N = 30; % filter length

M = 1; % delay

npt = N*(N+1)/2;

SF = 2048; % 12-bit ADC scaling

p0 = 0.05;

w0 = 1;

gamma = 0.98;

RemoveMean = 0; % 1 - remove the mean from the data, 0 - otherwise

delay = zeros(1,M);

U=zeros(1,npt);

U(1)=p0;

W = w0*ones(N,1);

X = zeros(N,1);

for i=1:N-1

ik=(i*(i+1)-2)/2+1;

U(ik)=p0;

end

if w0==0

sf = SF; % scaling factor for display

else

sf = SF/N/w0;

end

in = fopen(\'ADF.dat\',\'r\'); %read input data from specified data file

Y = fscanf(in,\'%g\',inf)/SF;

fclose(in);

if RemoveMean % remove the mean from the data if required

Y = Y - sum(Y)/length(Y);

end

for i=1:length(Y)

if M>0

delay(2:M+1) = delay(1:M); % shift input data in delay registers

end

delay(1) = Y(i);

X(2:N) = X(1:N-1); % update buffer

X(1) = delay(M+1);

E(i) = Y(i) - X\'*W; % the enhanced signal

W = uduflt(W,X,U,E(i),gamma ,N);

end

subplot(2,1,1),plot(1:length(Y),Y*SF); title(\'Input Signal\');

subplot(2,1,2),plot(1:length(E),E*sf); title(\'Enhanced Signal\');

3) % program to illustrate adaptive filtering using the square root RLS algorithm:

% X delayed input data vector

% Y measured signal

% W coefficient vector

% E enhanced signal

N = 30; % filter length

M = 1; % delay

npt = N*(N+1)/2;

SF = 2048; % 12-bit ADC scaling

p0 = 0.05;

w0 = 1;

gamma = 0.98;

RemoveMean = 0; % 1 - remove the mean from the data, 0 - otherwise

delay = zeros(1,M);

W = w0*ones(N,1);

X = zeros(N,1);

S = zeros(1,npt);

S(1)=p0;

for i=1:N-1

ik=(i*(i+1)-2)/2+1;

S(ik)=p0;

end

if w0==0

sf = SF; % scaling factor for display

else

sf = SF/N/w0;

end

in = fopen(\'ADF.dat\',\'r\'); %read input data from specified data file

Y = fscanf(in,\'%g\',inf)/SF;

fclose(in);

if RemoveMean % remove the mean from the data if required

Y = Y - sum(Y)/length(Y);

end

for i=1:length(Y)

if M>0

delay(2:M+1) = delay(1:M); % shift input data in delay registers

end

delay(1) = Y(i);

X(2:N) = X(1:N-1); % update buffer

X(1) = delay(M+1);

E(i) = Y(i) - X\'*W; % the enhanced signal

W = sqrtflt(W,X,E(i),S,gamma,N);

end

subplot(2,1,1),plot(1:length(Y),Y*SF); title(\'Input Signal\');

subplot(2,1,2),plot(1:length(E),E*sf); title(\'Enhanced Signal\');

4) % program to illustrate adaptive filtering using the RLS algorithm:

% X delayed input signal

% Y measured signal

% W coefficient vector

% E enhanced signal

N = 30; % filter length

M = 1; % stages of delay

SF = 2048; % 12-bit ADC scaling

p0 = 0.05;

w0 = 100;

gamma = 0.98;

RemoveMean = 0; % 1 to remove the mean, 0 otherwise

W = w0*ones(N,1); % adaptive filter weights

X = zeros(N,1);

delay = zeros(1,M+1);

P = p0*diag(ones(1,N),0);

if w0==0

sf = SF; % scaling factor for display

else

sf = SF/N/w0;

end

in = fopen(\'ADF.dat\',\'r\'); %read input data from specified data file

Y = fscanf(in,\'%g\',inf)/SF;

fclose(in);

if RemoveMean % remove the mean from the data if required

Y = Y - sum(Y)/length(Y);

end

for i=1:length(Y)

if M>0

delay(2:M+1) = delay(1:M); % shift input data in delay registers

end

delay(1) = Y(i);

X(2:N) = X(1:N-1); % update buffer

X(1) = delay(M+1);

E(i) = Y(i) - X\'*W; % the enhanced signal

G = P*X/(gamma + X\'*P*X);

P = (P - G*X\'*P)/gamma;

W = W + G*E(i); % update the weights

end

subplot(2,1,1),plot(1:length(Y),Y*SF); title(\'Input Signal\');

subplot(2,1,2),plot(1:length(E),E*sf); title(\'Enhanced Signal\');

5)   udu algorithm - a numerically stable form of the recursive least squares algorithm:

% inputs:

% x() input vector

% dn latest input data value

% w() coefficient vector

% u() vector containing elements of U and D

% outputs:

% en error signal

% yn digital filter output

% w() updated coefficient vector

% u() updated elements of U and D

sf = 1/gamma;

m=1; % update the UD elements

v=zeros(1,N);

v(1)=x(1);

for j=2:N

v(j)=x(j);

for k=1:j-1

m=m+1;

v(j)=v(j)+u(m)*x(k);

end

m=m+1;

b(j)=u(m)*v(j);

end

b(1)=u(1)*x(1);

alpha=gamma+b(1)*v(1);

delta=1/alpha;

u(1)=u(1)*delta;

m=1;

for j=2:N

beta1=alpha;

alpha=alpha+b(j)*v(j);

p=-v(j)*delta;

delta=1/alpha;

for k=1:j-1

m=m+1;

beta=u(m);

u(m)=beta+b(k)*p;

b(k)=b(k)+b(j)*beta;

end

m=m+1;

u(m)=u(m)*beta1*delta*sf;

end

perr=ek/alpha;

for j=1:N % update the weights

w(j)=w(j)+b(j)*perr;

end

Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y
Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y
Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y
Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y
Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y
Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y
Adaptive Algorithms i need a matlab code for itSolution1) %Program to illustrate adaptive filtering using the LMS algorithms: % X delayed input data vector % Y

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site