function [xls_new, Pinvsr_new ] = qr_rls( Pinvsr, xls, a, y ) % function [xls_new, Pinvsr_new ] = qr_rls( Pinvsr, xls, a, y ) % % QR version of recursive least-squares estimator for solving y=Px. % 'a' is a new row of matrix P, and 'y' is the associated target value. % % 'Pinvsr' is the square root of Pinv=(P'*P)^-1, % and should be LOWER triangular (ie, Pinvsr = chol(Pinv)' ). % 'a' should be specified as a column vector. % 'y' may be a row vector, in which case 'xls' will be a matrix. % % This version does not include a forgetting factor. % % D. Wingate 5/12/2006 % err = y - a'*xls; n = size(Pinvsr,1); M = [ 1, a'*Pinvsr ; zeros( n, 1 ), Pinvsr ]; % [Q,R] = qr( M ); R = triu( qr( M' ) ); Pinvsr_new = R( 2:1+n, 2:1+n )'; Kt = R( 1, 2:1+n )' / R(1,1); xls_new = xls + Kt * err; return;