Main Content

# rls

(To be removed) Construct recursive least squares (RLS) adaptive algorithm object

rls will be removed in a future release. Use `comm.LinearEqualizer` or `comm.DecisionFeedback` instead.

## Syntax

```alg = rls(forgetfactor) alg = rls(forgetfactor,invcorr0) ```

## Description

The `rls` function creates an adaptive algorithm object that you can use with the `lineareq` function or `dfe` function to create an equalizer object. You can then use the equalizer object with the `equalize` function to equalize a signal. To learn more about the process for equalizing a signal, see Equalization.

`alg = rls(forgetfactor)` constructs an adaptive algorithm object based on the recursive least squares (RLS) algorithm. The forgetting factor is `forgetfactor`, a real number between 0 and 1. The inverse correlation matrix is initialized to a scalar value.

`alg = rls(forgetfactor,invcorr0)` sets the initialization parameter for the inverse correlation matrix. This scalar value is used to initialize or reset the diagonal elements of the inverse correlation matrix.

### Properties

The table below describes the properties of the RLS adaptive algorithm object. To learn how to view or change the values of an adaptive algorithm object, see Equalization.

PropertyDescription
`AlgType`Fixed value, `'RLS'`
`ForgetFactor`Forgetting factor
`InvCorrInit`Scalar value used to initialize or reset the diagonal elements of the inverse correlation matrix

Also, when you use this adaptive algorithm object to create an equalizer object (via the `lineareq` function or `dfe` function), the equalizer object has an `InvCorrMatrix` property that represents the inverse correlation matrix for the RLS algorithm. The initial value of `InvCorrMatrix` is `InvCorrInit*eye(N)`, where `N` is the total number of equalizer weights.

## Examples

collapse all

This example configures the recommended `comm.LinearEqualizer` System object™ and the legacy `lineareq` feature with comparable settings.

Initialize Variables and Supporting Objects

```d = randi([0 3],1000,1); x = pskmod(d,4,pi/4); r = awgn(x,25); sps = 2; %samples per symbol for oversampled cases nTaps = 6; txFilter = comm.RaisedCosineTransmitFilter('FilterSpanInSymbols',nTaps, ... 'OutputSamplesPerSymbol',4); rxFilter = comm.RaisedCosineReceiveFilter('FilterSpanInSymbols',nTaps, ... 'InputSamplesPerSymbol',4,'DecimationFactor',2); x2 = txFilter(x); r2 = rxFilter(awgn(x2,25,0.5)); filterDelay = txFilter.FilterSpanInSymbols/2 + ... rxFilter.FilterSpanInSymbols/2; % Total filter delay in symbols```

To compare the equalized output, plot the constellations using code such as:

```% plot(yNew,'*') % hold on % plot(yOld,'o') % hold off; legend('New Eq','Old Eq'); grid on```

Use RLS Algorithm with Linear Equalizer

Configure `lineareq` and `comm.LinearEqualizer` objects with comparable settings.

`eqOld = lineareq(5,rls(0.95),pskmod(0:3,4,pi/4))`
```eqOld = EqType: 'Linear Equalizer' AlgType: 'RLS' nWeights: 5 nSampPerSym: 1 RefTap: 1 SigConst: [0.7071 + 0.7071i -0.7071 + 0.7071i -0.7071 - 0.7071i 0.7071 - 0.7071i] InvCorrInit: 0.1000 InvCorrMatrix: [5×5 double] Weights: [0 0 0 0 0] WeightInputs: [0 0 0 0 0] ResetBeforeFiltering: 1 NumSamplesProcessed: 0 ```
```eqNew = comm.LinearEqualizer('NumTaps',5,'Algorithm','RLS', ... 'ForgettingFactor',0.95,'Constellation',pskmod(0:3,4,pi/4),'ReferenceTap',1) ```
```eqNew = comm.LinearEqualizer with properties: Algorithm: 'RLS' NumTaps: 5 ForgettingFactor: 0.9500 InitialInverseCorrelationMatrix: 0.1000 Constellation: [0.7071 + 0.7071i -0.7071 + 0.7071i -0.7071 - 0.7071i 0.7071 - 0.7071i] ReferenceTap: 1 InputDelay: 0 InputSamplesPerSymbol: 1 TrainingFlagInputPort: false AdaptAfterTraining: true InitialWeightsSource: 'Auto' WeightUpdatePeriod: 1```

Call the equalizers. When `ResetBeforeFiltering` is set to `true`, each call of the `equalize` object resets the equalizer. To get the equivalent behavior call `reset` after each call of the `comm.LinearEqualizer` object.

```yOld1 = equalize(eqOld,r,x(1:100)); yOld2 = equalize(eqOld,r,x(1:100)); yNew1 = eqNew(r,x(1:100)); reset(eqNew) yNew2 = eqNew(r,x(1:100));```

Configure `lineareq` and `comm.LinearEqualizer` objects with comparable settings. For the `comm.LinearEqualizer` object, set the initial inverse correlation matrix to `eye(5)*0.2`.

`eqOld = lineareq(5,rls(0.95),pskmod(0:3,4,pi/4))`
```eqOld = EqType: 'Linear Equalizer' AlgType: 'RLS' nWeights: 5 nSampPerSym: 1 RefTap: 1 SigConst: [0.7071 + 0.7071i -0.7071 + 0.7071i -0.7071 - 0.7071i 0.7071 - 0.7071i] ForgetFactor: 0.9500 InvCorrInit: 0.1000 InvCorrMatrix: [5×5 double] Weights: [0 0 0 0 0] WeightInputs: [0 0 0 0 0] ResetBeforeFiltering: 1 NumSamplesProcessed: 0 ```
```eqNew = comm.LinearEqualizer('NumTaps',5,'Algorithm','RLS', ... 'ForgettingFactor',0.95,'Constellation',pskmod(0:3,4,pi/4),'ReferenceTap',1, ... 'InitialInverseCorrelationMatrix',eye(5)*0.2) ```
```eqNew = comm.LinearEqualizer with properties: Algorithm: 'RLS' NumTaps: 5 ForgettingFactor: 0.9500 InitialInverseCorrelationMatrix: [5×5 double] Constellation: [0.7071 + 0.7071i -0.7071 + 0.7071i -0.7071 - 0.7071i 0.7071 - 0.7071i] ReferenceTap: 1 InputDelay: 0 InputSamplesPerSymbol: 1 TrainingFlagInputPort: false AdaptAfterTraining: true InitialWeightsSource: 'Auto' WeightUpdatePeriod: 1```

Call the equalizers. When `ResetBeforeFiltering` is set to `true`, each call of the `equalize` object resets the equalizer. To get the equivalent behavior call `reset` after each call of the `comm.LinearEqualizer` object.

```yOld1 = equalize(eqOld,r,x(1:100)); yOld2 = equalize(eqOld,r,x(1:100)); yNew1 = eqNew(r,x(1:100)); reset(eqNew) yNew2 = eqNew(r,x(1:100));```

## Algorithms

Referring to the schematics presented in Equalization, define w as the vector of all weights wi and define u as the vector of all inputs ui. Based on the current set of inputs, u, and the current inverse correlation matrix, P, this adaptive algorithm first computes the Kalman gain vector, K

`$K=\frac{Pu}{\left(ForgettingFactor\right)+{u}^{H}Pu}.$`

where H denotes the Hermitian transpose.

Then the new inverse correlation matrix is given by

(`ForgetFactor`)-1(P – KuHP)

and the new set of weights is given by

w + K*e

where the * operator denotes the complex conjugate.

## Compatibility Considerations

expand all

Warns starting in R2020a

## References

[1] Farhang-Boroujeny, B., Adaptive Filters: Theory and Applications, Chichester, England, John Wiley & Sons, 1998.

[2] Haykin, S., Adaptive Filter Theory, Third Ed., Upper Saddle River, NJ, Prentice-Hall, 1996.

[3] Kurzweil, J., An Introduction to Digital Communications, New York, John Wiley & Sons, 2000.

[4] Proakis, John G., Digital Communications, Fourth Ed., New York, McGraw-Hill, 2001.

## See Also

### Topics

Introduced before R2006a

## Support

#### Bridging Wireless Communications Design and Testing with MATLAB

Download white paper