• No results found

adaptfilt.qrdlsl 0 200 400 600 800

−6 −4 −2 0 2 4 6 In−Phase Components Time Index Signal Value Desired Output Error 0 200 400 600 800 1000 −6 −4 −2 0 2 4 6 Quadrature Components Time Index Signal Value Desired Output Error −2 0 2 −3 −2 −1 0 1 2 3

Received Signal Scatter Plot

Real[x] Imag[x] −2 0 2 −3 −2 −1 0 1 2 3

Equalized Signal Scatter Plot

Real[y]

Imag[y]

See Also

adaptfilt.qrdrls,adaptfilt.gal,adaptfilt.ftf,adaptfilt.lsl

References

Haykin, S.,Adaptive Filter Theory, 2nd Edition, Prentice Hall, N.J., 1991

Purpose

FIR adaptive filter that uses QR-decomposition-based RLS

Syntax

ha = adaptfilt.qrdrls(l,lambda,sqrtcov,coeffs,states)

Description

ha = adaptfilt.qrdrls(l,lambda,sqrtcov,coeffs,states)

constructs an FIR QR-decomposition-based recursive-least squares (RLS) adaptive filter objectha.

Input Arguments

Entries in the following table describe the input arguments for

adaptfilt.qrdrls.

Input

Argument Description

l Adaptive filter length (the number of coefficients or

taps) and it must be a positive integer.ldefaults to 10. lambda RLS forgetting factor. This is a scalar and should lie

within the range (0, 1]. lambdadefaults to 1.

sqrtcov Upper-triangular Cholesky (square root) factor of the

input covariance matrix. Initialize this matrix with a positive definite upper triangular matrix.

coeffs Vector of initial filter coefficients. It must be a length lvector. coeffsdefaults to lengthlvector whose

elements are zeros.

states Vector of initial filter states. It must be a lengthl-1

vector. statesdefaults to a lengthl-1 vector of zeros.

Properties

Since youradaptfilt.qrdrlsfilter is an object, it has properties that

define its behavior in operation. Note that many of the properties are also input arguments for creatingadaptfilt.qrdrlsobjects. To

show you the properties that apply, this table lists and describes each property for the filter object.

adaptfilt.qrdrls

Name Range Description

Algorithm None Defines the adaptive filter

algorithm the object uses during adaptation

Coefficients Vector of length l

Vector containing the initial filter coefficients. It must be a lengthlvector where l is the number of filter

coefficients. coeffsdefaults

to lengthlvector of zeros

when you do not provide the argument for input.

FilterLength Any positive

integer Reports the length ofthe filter, the number of coefficients or taps

ForgettingFactor Scalar Forgetting factor of the

adaptive filter. This is a scalar and should lie in the range (0, 1]. It defaults to 1. Setting

forgetting factor =1

denotes infinite memory while adapting to find the new filter. Note that this is thelambdainput argument.

Name Range Description

PersistentMemory falseortrue Determine whether the

filter states get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter if you have not changed the filter since you constructed it.

PersistentMemoryreturns

to zero any state that the filter changes during processing. States that the filter does not change are not affected. Defaults tofalse. SqrtCov Square matrix

with each dimension equal to the filter lengthl

Upper-triangular Cholesky (square root) factor of the input covariance matrix. Initialize this matrix with a positive definite upper triangular matrix.

States Vector of

elements Vector of the adaptivefilter states. states

defaults to a vector of zeros which has length equal to (l+projectord- 2).

Examples

System Identification of a 32-coefficient FIR filter (500 iterations).

x = randn(1,500); % Input to the filter

b = fir1(31,0.5); % FIR system to be identified

n = 0.1*randn(1,500); % Observation noise signal

d = filter(b,1,x)+n; % Desired signal

adaptfilt.qrdrls

lam = 0.99; % RLS forgetting factor

ha = adaptfilt.qrdrls(32,lam,G0); [y,e] = filter(ha,x,d);

subplot(2,1,1); plot(1:500,[d;y;e]);

title('System Identification of an FIR Filter'); legend('Desired','Output','Error');

xlabel('Time Index'); ylabel('Signal Value'); subplot(2,1,2); stem([b.',ha.Coefficients.']); legend('Actual','Estimated'); grid on;

xlabel('Coefficient #'); ylabel('Coefficient Value');

Using this variant of the RLS algorithm successfully identifies the unknown FIR filter, as shown here.

0 50 100 150 200 250 300 350 400 450 500 −3 −2 −1 0 1 2 3

System Identification of an FIR Filter

Time Index Signal Value Desired Output Error 0 5 10 15 20 25 30 35 −0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 Coefficient # Coefficient Value Actual Estimated

See Also

adaptfilt.rls, adaptfilt.hrls, adaptfilt.hswrls, adaptfilt.swrls

Purpose

FIR adaptive filter that uses direct form RLS

Syntax

ha = adaptfilt.rls(l,lambda,invcov,coeffs,states)

Description

ha = adaptfilt.rls(l,lambda,invcov,coeffs,states)constructs

an FIR direct form RLS adaptive filterha.

Input Arguments

Entries in the following table describe the input arguments for

adaptfilt.rls.

Input

Argument Description

l Adaptive filter length (the number of coefficients or

taps) and it must be a positive integer. ldefaults

to 10.

lambda RLS forgetting factor. This is a scalar and should

lie in the range (0, 1].lambdadefaults to 1. invcov Inverse of the input signal covariance matrix. For

best performance, you should initialize this matrix to be a positive definite matrix.

coeffs Vector of initial filter coefficients. it must be a

lengthlvector. coeffsdefaults to lengthlvector

with elements equal to zero.

states Vector of initial filter states for the adaptive filter.

It must be a lengthl-1 vector.statesdefaults to a

length l-1 vector of zeros.

Properties

Since youradaptfilt.rlsfilter is an object, it has properties that

define its behavior in operation. Note that many of the properties are also input arguments for creatingadaptfilt.rlsobjects. To show you

the properties that apply, this table lists and describes each property for the filter object.

adaptfilt.rls

Name Range Description

Algorithm None Defines the adaptive filter

algorithm the object uses during adaptation.

Coefficients Vector

containing

lelements

Vector containing the initial filter coefficients. It must be a length

lvector wherelis the number of

filter coefficients. coeffsdefaults

to lengthl vector of zeros when

you do not provide the argument for input.

FilterLength Any

positive integer

Reports the length of the filter, the number of coefficients or taps. Remember that filter length is filter order + 1.

ForgettingFactor Scalar Forgetting factor of the adaptive

filter. This is a scalar and should lie in the range (0, 1]. It defaults to 1. Settingforgetting factor =1

denotes infinite memory while adapting to find the new filter. Note that this is thelambdainput

argument.

InvCov Matrix of

sizel-by-l

Upper-triangular Cholesky (square root) factor of the input covariance matrix. Initialize this matrix with a positive definite upper triangular matrix.

KalmanGain Vector of

size (l,1)

Empty when you construct the object, this gets populated after you run the filter.

Name Range Description

PersistentMemory false or true

Determine whether the filter states get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter if you have not changed the filter since you constructed it.

PersistentMemoryreturns to zero

any state that the filter changes during processing. Defaults to

false. States Double

array Vector of the adaptive filter states.statesdefaults to a vector of

zeros which has length equal to (l+projectord- 2).

Examples

System Identification of a 32-coefficient FIR filter over 500 adaptation iterations.

x = randn(1,500); % Input to the filter

b = fir1(31,0.5); % FIR system to be identified

n = 0.1*randn(1,500); % Observation noise signal

d = filter(b,1,x)+n; % Desired signal

P0 = 10*eye(32); % Initial sqrt correlation matrix inverse

lam = 0.99; % RLS forgetting factor

ha = adaptfilt.rls(32,lam,P0); [y,e] = filter(ha,x,d);

subplot(2,1,1); plot(1:500,[d;y;e]);

title('System Identification of an FIR Filter'); legend('Desired','Output','Error');

xlabel('Time Index'); ylabel('Signal Value'); subplot(2,1,2); stem([b.',ha.Coefficients.']); legend('Actual','Estimated');

adaptfilt.rls

In this example of adaptive filtering using the RLS algorithm to update the filter coefficients for each iteration, the figure shown reveals the fidelity of the derived filter after adaptation.

0 50 100 150 200 250 300 350 400 450 500 −3 −2 −1 0 1 2 3

System Identification of an FIR Filter

Time Index Signal Value Desired Output Error 0 5 10 15 20 25 30 35 −0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 Coefficient # Coefficient valUe Actual Estimated

Purpose

FIR adaptive filter that uses sign-data algorithm

Syntax

ha = adaptfilt.sd(l,step,leakage,coeffs,states)

Description

ha = adaptfilt.sd(l,step,leakage,coeffs,states)constructs an

FIR sign-data adaptive filter objectha.

Input Arguments

Entries in the following table describe the input arguments for

adaptfilt.sd.

Input

Argument Description

l Adaptive filter length (the number of coefficients or

taps) and it must be a positive integer. ldefaults

to 10.

step SD step size. It must be a nonnegative scalar.step

defaults to 0.1

leakage Your SD leakage factor. It must be a scalar

between 0 and 1. Whenleakageis less than one, adaptfilt.sdimplements a leaky SD algorithm.

When you omit theleakageproperty in the calling

syntax, it defaults to 1 providing no leakage in the adapting algorithm.

coeffs Vector of initial filter coefficients. it must be a

lengthlvector. coeffsdefaults to lengthlvector

with elements equal to zero.

states Vector of initial filter states for the adaptive filter.

It must be a lengthl-1 vector.statesdefaults to a

length l-1 vector of zeros.

Properties

In the syntax for creating theadaptfiltobject, the input options are

adaptfilt.sd

sign-data objects, their default values, and a brief description of the property.

Property

Default

Value Description

Al gorithm Sign-data Defines the adaptive filter

algorithm the object uses during adaptation.

Coefficients zeros(1,l) Vector containing the initial

filter coefficients. It must be a lengthlvector wherelis the

number of filter coefficients.

coeffsdefaults to lengthl

vector of zeros when you do not provide the argument for input. Should be initialized with the initial coefficients for the FIR filter prior to adapting. You needlentries in coefficients.

FilterLength 10 Reports the length of the filter,

the number of coefficients or taps.

Leakage 0 Specifies the leakage

parameter. Allows you to implement a leaky algorithm. Including a leakage factor can improve the results of the algorithm by forcing the algorithm to continue to adapt even after it reaches a minimum value. Ranges between 0 and 1. Defaults to 0.

Property

Default

Value Description

PersistentMemory falseortrue Determine whether the filter

states and coefficients get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter. PersistentMemory

returns to zero any property value that the filter changes during processing. Property values that the filter does not change are not affected. Defaults tofalse.

States zeros(l-1,1) Vector of the adaptive filter

states. statesdefaults to a

vector of zeros which has length equal to (l- 1).

StepSize 0.1 Sets the SD algorithm step

size used for each iteration of the adapting algorithm. Determines both how quickly and how closely the adaptive filter converges to the filter solution.

Example

Adaptive line enhancement using a 32-coefficient FIR filter to perform the enhancement. This example runs for 5000 iterations, as you see in propertyiter.

d = 1; % Number of samples of delay

ntr= 5000; % Number of iterations

v = sin(2*pi*0.05*[1:ntr+d]); % Sinusoidal signal

adaptfilt.sd

x = v(1:ntr)+n(1:ntr); % Input signal

d = v(1+d:ntr+d)+n(1+d:ntr+d); % Desired signal

mu = 0.0001; % Sign-data step size.

ha = adaptfilt.sd(32,mu); [y,e] = filter(ha,x,d);

subplot(2,1,1); plot(1:ntr,[d;y;v(1:end-1)]); axis([ntr-100 ntr -3 3]);

title('Adaptive Line Enhancement of a Noisy Sinusoidal Signal'); legend('Observed','Enhanced','Original');

xlabel('Time Index'); ylabel('Signal Value'); [pxx,om] = pwelch(x(ntr-1000:ntr));

pyy = pwelch(y(ntr-1000:ntr)); subplot(2,1,2);

plot(om/pi,10*log10([pxx/max(pxx),pyy/max(pyy)])); axis([0 1 -60 20]); legend('Observed','Enhanced'); xlabel('Normalized Frequency (\times \pi rad/sample)'); ylabel('Power Spectral Density'); grid on;

4900 4910 4920 4930 4940 4950 4960 4970 4980 4990 5000 −3 −2 −1 0 1 2 3

Adaptive Line Enhancement of a Noisy Sinusoidal Signal

Time Index Signal Value 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 −60 −40 −20 0 20

Normalized Frequency (×π rad/sample)

Power Spectral Density

Observed Enhanced Original

Observed Enhanced

Each of the variants — sign-data, sign-error, and sign-sign — uses the same example. You can compare the results by viewing the figure shown for each adaptive filter method —adaptfilt.sd,adaptfilt.se,

andadaptfilt.ss.

See Also

adaptfilt.lms,adaptfilt.se,adaptfilt.ss

References

Moschner, J.L., “Adaptive Filter with Clipped Input Data,” Ph.D. thesis, Stanford Univ., Stanford, CA, June 1970.

Hayes, M., Statistical Digital Signal Processing and Modeling, New York Wiley, 1996.

adaptfilt.se

Purpose

FIR adaptive filter that uses sign-error algorithm

Syntax

ha = adaptfilt.se(l,step,leakage,coeffs,states)

Description

ha = adaptfilt.se(l,step,leakage,coeffs,states)constructs an

FIR sign-error adaptive filterha.

Input Arguments

Entries in the following table describe the input arguments for

adaptfilt.se.

Input

Argument Description

l Adaptive filter length (the number of coefficients or

taps) and it must be a positive integer. ldefaults

to 10.

step SE step size. It must be a nonnegative scalar. You

can usemaxstepto determine a reasonable range

of step size values for the signals being processed.

stepdefaults to 0.1

leakage Your SE leakage factor. It must be a scalar

between 0 and 1. Whenleakageis less than one, adaptfilt.seimplements a leaky SE algorithm.

When you omit theleakageproperty in the calling

syntax, it defaults to 1 providing no leakage in the adapting algorithm.

coeffs Vector of initial filter coefficients. it must be a

lengthlvector. coeffsdefaults to lengthlvector

with elements equal to zero.

states Vector of initial filter states for the adaptive filter.

It must be a lengthl-1 vector. statesdefaults to a

Properties

In the syntax for creating theadaptfiltobject, the input options are

properties of the object you create. This table lists the properties for the sign-error SD object, their default values, and a brief description of the property.

Property

Default

Value Description

Algorithm Sign-error Defines the adaptive filter

algorithm the object uses during adaptation

Coefficients zeros(1,l) Vector containing the initial

filter coefficients. It must be a lengthl vector wherelis the

number of filter coefficients.

coeffsdefaults to length l

vector of zeros when you do not provide the argument for input. Should be initialized with the initial coefficients for the FIR filter prior to adapting.

FilterLength 10 Reports the length of the filter,

the number of coefficients or taps

Leakage 1 Specifies the leakage parameter.

Allows you to implement a leaky algorithm. Including a leakage factor can improve the results of the algorithm by forcing the algorithm to continue to adapt even after it reaches a minimum value. Ranges between 0 and 1. Defaults to one if omitted.

adaptfilt.se

Property

Default

Value Description

PersistentMemory falseortrue Determine whether the filter

states and coefficients get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter.

PersistentMemoryreturns to

zero any property value that the filter changes during processing. Property values that the filter does not change are not affected. Defaults tofalse.

States zeros(l-1,1) Vector of the adaptive filter

states. statesdefaults to a

vector of zeros which has length equal to (l -1).

StepSize 0.1 Sets the SE algorithm step size

used for each iteration of the adapting algorithm. Determines both how quickly and how closely the adaptive filter converges to the filter solution. Useinspect(ha)to view or change the object properties graphically

using the MATLAB Property Inspector.

Examples

Adaptive line enhancement using a 32-coefficient FIR filter running over 5000 iterations.

d = 1; % Number of samples of delay

ntr= 5000; % Number of iterations

v = sin(2*pi*0.05*[1:ntr+d]); % Sinusoidal signal

x = v(1:ntr)+n(1:ntr); % Input signal --(delayed desired signal)

d = v(1+d:ntr+d)+n(1+d:ntr+d); % Desired signal

mu = 0.0001; % Sign-error step size

ha = adaptfilt.se(32,mu); [y,e] = filter(ha,x,d); subplot(2,1,1);

plot(1:ntr,[d;y;v(1:end-1)]); axis([ntr-100 ntr -3 3]);

title('Adaptive Line Enhancement of Noisy Sinusoid'); legend('Observed','Enhanced','Original');

xlabel('Time Index'); ylabel('Signal Value');

[pxx,om] = pwelch(x(ntr-1000:ntr)); pyy = pwelch(y(ntr-1000:ntr)); subplot(2,1,2); plot(om/pi,10*log10([pxx/max(pxx),pyy/max(pyy)])); axis([0 1 -60 20]); legend('Observed','Enhanced');

xlabel('Normalized Frequency (\times \pi rad/sample)'); ylabel('Power Spectral Density'); grid on;

Compare the figure shown here to the ones foradaptfilt.sdand adaptfilt.ssto see how the variants perform on the same example.

adaptfilt.se

4900 4910 4920 4930 4940 4950 4960 4970 4980 4990 5000 −3 −2 −1 0 1 2 3

Adaptive Line Enhancement of a Noisy Sinusoidal Signal

Time Index Signal Value 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 −60 −40 −20 0 20

Normalized Frequency (×π rad/sample)

Power Spectral Density

Observed Enhanced Original

Observed Enhanced

See Also

adaptfilt.sd,adaptfilt.ss,adaptfilt.lms

References

Gersho, A, “Adaptive Filtering With Binary Reinforcement,” IEEE Trans. Information Theory, vol. IT-30, pp. 191-199, March 1984. Hayes, M, Statistical Digital Signal Processing and Modeling, New York, Wiley, 1996.

Purpose

FIR adaptive filter that uses sign-sign algorithm

Syntax

ha = adaptfilt.ss(l,step,leakage,coeffs,states)

Description

ha = adaptfilt.ss(l,step,leakage,coeffs,states)constructs an

FIR sign-error adaptive filterha.

Input Arguments

Entries in the following table describe the input arguments for

adaptfilt.ss.

Input

Argument Description

l Adaptive filter length (the number of coefficients

or taps) and it must be a positive integer. l

defaults to 10.

step SS step size. It must be a nonnegative scalar. step

defaults to 0.1.

leakage Your SS leakage factor. It must be a scalar

between 0 and 1. Whenleakageis less than one, adaptfilt.lmsimplements a leaky SS algorithm.

When you omit theleakageproperty in the calling

syntax, it defaults to 1 providing no leakage in the adapting algorithm.

coeffs Vector of initial filter coefficients. it must be a

lengthlvector. coeffsdefaults to lengthlvector

with elements equal to zero.

states Vector of initial filter states for the adaptive filter.

It must be a lengthl-1 vector. statesdefaults to

a length l-1 vector of zeros.

adaptfilt.sscan be called for a block of data, whenxanddare vectors,

or in “sample by sample mode” using a For-loop with the method filter:

adaptfilt.ss

ha = adaptfilt.ss(25,0.9);

[y(n),e(n)] = filter(ha,(x(n),d(n),s)); end

Properties

In the syntax for creating theadaptfiltobject, most of the input

options are properties of the object you create. This table lists the properties for sign-sign objects, their default values, and a brief description of the property.

Property

Default

Value Description

Algorithm Sign-sign Defines the adaptive filter

algorithm the object uses during adaptation

Coefficients zeros(1,l) Vector containing the initial

filter coefficients. It must be a lengthlvector wherelis the

number of filter coefficients.

coeffsdefaults to length l

vector of zeros when you do not provide the argument for input. Should be initialized with the initial coefficients for the FIR filter prior to adapting.

FilterLength 10 Reports the length of the filter,

the number of coefficients or taps

Property

Default

Value Description

Leakage 1 Specifies the leakage parameter.

Allows you to implement a leaky algorithm. Including a leakage factor can improve the results of the algorithm by forcing the algorithm to continue to adapt even after it reaches a minimum value. Ranges between 0 and 1. 1 is the default value.

PersistentMemory falseortrue Determine whether the filter

states and coefficients get restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter.

PersistentMemoryreturns to

zero any property value that the filter changes during processing. Property values that the filter does not change are not affected. Defaults tofalse.

States zeros(l-1,1) Vector of the adaptive filter

states. statesdefaults to a

vector of zeros which has length equal to (l-1).

StepSize 0.1 Sets the SE algorithm step

size used for each iteration of the adapting algorithm. Determines both how quickly and how closely the adaptive filter converges to the filter solution.

adaptfilt.ss

Examples

Demonstrating adaptive line enhancement using a 32-coefficient FIR filter provides a good introduction to the sign-sign algorithm.

d = 1; % number of samples of delay

ntr= 5000; % number of iterations

v = sin(2*pi*0.05*[1:ntr+d]); % sinusoidal signal

n = randn(1,ntr+d); % noise signal

x = v(1:ntr)+n(1:ntr); % Delayed input signal

d = v(1+d:ntr+d)+n(1+d:ntr+d); % desired signal

mu = 0.0001; % sign-sign step size

ha = adaptfilt.ss(32,mu); [y,e] = filter(ha,x,d); subplot(2,1,1);

plot(1:ntr,[d;y;v(1:end-1)]); axis([ntr-100 ntr -3 3]); title('Adaptive Line Enhancement of a Noisy Sinusoid'); legend('Observed','Enhanced','Original');

xlabel('Time Index'); ylabel('Signal Value');

[pxx,om] = pwelch(x(ntr-1000:ntr)); pyy = pwelch(y(ntr-1000:ntr)); subplot(2,1,2);

plot(om/pi,10*log10([pxx/max(pxx),pyy/max(pyy)])); axis([0 1 -60 20]); legend('Observed','Enhanced'); xlabel('Normalized Frequency (\times \pi rad/sample)'); ylabel('Power Spectral Density'); grid on;

This example is the same as the ones used for the sign-data and sign-error examples. Comparing the figures shown for each of the others lets you assess the performance of each for the same task.

4900 4910 4920 4930 4940 4950 4960 4970 4980 4990 5000 −3 −2 −1 0 1 2 3

Adaptive Line Enhancement of a Noisy Sinusoidal Signal

Time Index Signal Value Observed Enhanced Original 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 −60 −40 −20 0 20

Normalized Frequency (×π rad/sample)

Power Spectral Density

Observed Enhanced

See Also

adaptfilt.se,adaptfilt.sd,adaptfilt.lms

References

Lucky, R.W, “Techniques For Adaptive Equalization of Digital

Communication Systems,” Bell Systems Technical Journal, vol. 45, pp. 255-286, Feb. 1966

Hayes, M., Statistical Digital Signal Processing and Modeling, New York, Wiley, 1996.

adaptfilt.swftf

Purpose

FIR adaptive filter that uses sliding window fast transversal least squares

Syntax

ha = adaptfilt.swftf(l,delta,blocklen,gamma,gstates, dstates,...coeffs,states)

Description

ha = adaptfilt.swftf(l,delta,blocklen,gamma,gstates, dstates,...coeffs,states)constructs a sliding window fast

transversal least squares adaptive filterha.

Input Arguments

Entries in the following table describe the input arguments for

adaptfilt.swftf.

Input

Argument Description

l Adaptive filter length (the number of coefficients or

taps) and it must be a positive integer. ldefaults to

10.

delta Soft-constrained initialization factor. This scalar