Mercurial > forge
changeset 10181:7a304f7f9bd5 octave-forge
control-devel: use filt instead of tf
author | paramaniac |
---|---|
date | Sun, 06 May 2012 15:53:35 +0000 |
parents | 93615b0e893f |
children | 3d361bf5be76 |
files | extra/control-devel/inst/arx.m |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/extra/control-devel/inst/arx.m Sun May 06 14:32:55 2012 +0000 +++ b/extra/control-devel/inst/arx.m Sun May 06 15:53:35 2012 +0000 @@ -28,13 +28,13 @@ PhiU = toeplitz (U(1:end-1, :), [U(1, :); zeros(nb-1, 1)]); Phi = [-PhiY, PhiU]; - Theta = Phi \ Y(2:end, :) # naive formula + ## Theta = Phi \ Y(2:end, :); # naive formula ## solve linear least squares problem by pseudoinverse ## the pseudoinverse is computed by singular value decomposition ## M = U S V* ---> M+ = V S+ U* ## Th = Ph \ Y = Ph+ Y - ## Th = V S+ U' Y, S+ = 1 ./ diag (S) + ## Th = V S+ U* Y, S+ = 1 ./ diag (S) [U, S, V] = svd (Phi, 0); # 0 for "economy size" decomposition, U overwrites input U S = diag (S); # extract main diagonal @@ -42,11 +42,11 @@ V = V(:, 1:r); S = S(1:r); U = U(:, 1:r); - Theta = V * (S .\ (U' * Y(2:end, :))) # U' is the conjugate transpose + Theta = V * (S .\ (U' * Y(2:end, :))); # U' is the conjugate transpose - A = [1; Theta(1:na)]; # a0 = 1, a1 = Theta(1), an = Theta(n) - B = Theta(na+1:end); # b0 = 0 (leading zeros are removed by tf, no need to add one) + A = [1; Theta(1:na)]; # a0 = 1, a1 = Theta(1), an = Theta(n) + B = [0; Theta(na+1:end)]; # b0 = 0 (leading zero required by filt) - sys = tf ({B, 1}, {A, A}, Ts); + sys = filt ({B, 1}, {A, A}, Ts); endfunction \ No newline at end of file