Main Content

fixed.qlessQRUpdate

Update QR factorization

Since R2020b

Description

R = fixed.qlessQRUpdate(R, y) updates upper-triangular R with vector y.

This syntax is equivalent to

[~,R] = qr([R;y],0);

example

R = fixed.qlessQRUpdate(R, y, forgettingFactor) updates upper-triangular R with vector y and multiplies the result by the value specified by forgettingFactor.

This syntax is equivalent to

[~,R] = qr([R;y],0);
R(:) = forgettingFactor * R;

example

Examples

collapse all

This example shows how to update the upper-triangular factor of a matrix as new data streams in.

Define a matrix and compute the upper-triangular factor, R, using the fixed.qlessQR function.

rng('default');
m = 20;
n = 4;
A = randn(m,n)
A = 20×4

    0.5377    0.6715   -0.1022   -1.0891
    1.8339   -1.2075   -0.2414    0.0326
   -2.2588    0.7172    0.3192    0.5525
    0.8622    1.6302    0.3129    1.1006
    0.3188    0.4889   -0.8649    1.5442
   -1.3077    1.0347   -0.0301    0.0859
   -0.4336    0.7269   -0.1649   -1.4916
    0.3426   -0.3034    0.6277   -0.7423
    3.5784    0.2939    1.0933   -1.0616
    2.7694   -0.7873    1.1093    2.3505
      ⋮

R = fixed.qlessQR(A)
R = 4×4

    7.1017   -2.0103    1.1646    0.7999
         0    4.8784    0.5745   -0.3222
         0         0    3.1658   -0.4570
         0         0         0    4.4965

As new data arrives, for example new values from a sensor array, you can use the fixed.qlessQRUpdate function to update the upper-triangular factor with the new data.

y1 = [1,1,1,1];
R = fixed.qlessQRUpdate(R,y1)
R = 4×4

    7.1718   -1.8513    1.2927    0.9315
         0    5.0412    0.7646   -0.0904
         0         0    3.2332   -0.2584
         0         0         0    4.6074

y2 = [1,1,1,1];
R = fixed.qlessQRUpdate(R,y2)
R = 4×4

    7.2411   -1.6954    1.4184    1.0607
         0    5.1929    0.9371    0.1191
         0         0    3.2892   -0.0962
         0         0         0    4.6928

The result of updating the upper-triangular factor as new data arrives is equivalent to computing the upper-triangular factor with all of the data.

R = fixed.qlessQR([A;y1;y2])
R = 4×4

    7.2411   -1.6954    1.4184    1.0607
         0    5.1929    0.9371    0.1191
         0         0    3.2892   -0.0962
         0         0         0    4.6928

When you want to stream an indefinite number of rows continuously, such as reading values from a sensor array continuously, without accumulating the data without bound, specify a forgetting factor.

forgettingFactor = exp(-1/(2*m))
forgettingFactor = 
0.9753
y3 = [1, 1, 1, 1];
R = fixed.qlessQRUpdate(R,y3,forgettingFactor)
R = 4×4

    7.1294   -1.5046    1.5038    1.1582
         0    5.2031    1.0676    0.3020
         0         0    3.2543    0.0379
         0         0         0    4.6431

Input Arguments

collapse all

Upper triangular input, specified as a matrix.

Data Types: single | double | fi
Complex Number Support: Yes

Measurement input, specified as a vector.

Data Types: single | double | fi
Complex Number Support: Yes

Forgetting factor, specified as a nonnegative scalar between 0 and 1. The forgetting factor determines how much weight past data is given. The forgettingFactor value is multiplied by R after each row of R is processed.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Output Arguments

collapse all

Updated upper-triangular factor, returned as a matrix.

Extended Capabilities

Version History

Introduced in R2020b