MIMO_LS_CovJacob

PURPOSE ^

SYNOPSIS ^

function TheCovJacob = MIMO_LS_CovJacob(data, xMat, ModelVar);

DESCRIPTION ^

      TheCovJacob = MIMO_LS_CovJacob(data, xMat, ModelVar)

   Calculates the column covariance matrix jacobian matrix w.r.t. ALL the plant and transient model parameters.
    The selection of the free model parameters, and the imposition of the model constraints
    (reciprocity) is done in a seperate routine


 Output parameters

     TheCovJacob     =    jacobian matrix, size: ntheta x ntheta x F


 Input parameters

        data        =    structure containing the non-parametric data
                            data.Y            =    DFT spectrum ny x 1 output signal, size: ny x F 
                            data.U            =    DFT spectrum nu x 1 input signal, size: nu x F 
                            data.freq        =    vector of frequency values (Hz), size: F x 1
                            data.Ts            =    sampling time (s)
                            data.CY         =    (sample) noise covariance matrix of 1 MIMO experiment Y 
                           data.CU         =   (sample) noise covariance matrix of 1 MIMO experiment U  
                           data.CYU        =   (sample) noise covariance matrix of 1 MIMO experiment U 
                            data.sqrtWinv    =    square root of the inverse of the weighting matrix W, size: ny x ny x F 
                            data.DC            =    1 if DC present otherwise 0
                            data.Nyquist    =    1 if Nyquist frequency present otherwise 0

        xMat        =    structure with tables of powers of (jwk)^r or (zk^-r)
                            xMat.Plant        =    plant model, size: F x max order

        ModelVar    =    contains the information about the model to be identified
                        structure with fields 'Transient', 'ThePlane', 'TheModel', 'Reciprocal', ...
                            ModelVar.Transient        =    1 then the initial conditions of the plant and/or noise are estimated
                            ModelVar.PlantPlane        =    plane of the plant
                            model
                                                            's':    continuous-time;
                                                            'w':    sqrt(s)-domain
                                                            'z':    discrete-time;
                                                            '':        plane not defined
                            ModelVar.RecipPlant        =    1 if plant model is reciprocal: G(i,j) = G(j,i)
                            ModelVar.nu                =    number of inputs
                            ModelVar.ny                =     number of outputs
                            ModelVar.na                =    order polynomial A
                            ModelVar.nb                =     order matrix polynomial B
                            ModelVar.nig            =    order vector polynomial Ig


 Copyright (c) Rik Pintelon, Vrije Universiteit Brussel - dept. ELEC, 30 November 2009
 All rights reserved.
 Software can be used freely for non-commercial applications only.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function TheCovJacob = MIMO_LS_CovJacob(data, xMat, ModelVar);
0002 %
0003 %      TheCovJacob = MIMO_LS_CovJacob(data, xMat, ModelVar)
0004 %
0005 %   Calculates the column covariance matrix jacobian matrix w.r.t. ALL the plant and transient model parameters.
0006 %    The selection of the free model parameters, and the imposition of the model constraints
0007 %    (reciprocity) is done in a seperate routine
0008 %
0009 %
0010 % Output parameters
0011 %
0012 %     TheCovJacob     =    jacobian matrix, size: ntheta x ntheta x F
0013 %
0014 %
0015 % Input parameters
0016 %
0017 %        data        =    structure containing the non-parametric data
0018 %                            data.Y            =    DFT spectrum ny x 1 output signal, size: ny x F
0019 %                            data.U            =    DFT spectrum nu x 1 input signal, size: nu x F
0020 %                            data.freq        =    vector of frequency values (Hz), size: F x 1
0021 %                            data.Ts            =    sampling time (s)
0022 %                            data.CY         =    (sample) noise covariance matrix of 1 MIMO experiment Y
0023 %                           data.CU         =   (sample) noise covariance matrix of 1 MIMO experiment U
0024 %                           data.CYU        =   (sample) noise covariance matrix of 1 MIMO experiment U
0025 %                            data.sqrtWinv    =    square root of the inverse of the weighting matrix W, size: ny x ny x F
0026 %                            data.DC            =    1 if DC present otherwise 0
0027 %                            data.Nyquist    =    1 if Nyquist frequency present otherwise 0
0028 %
0029 %        xMat        =    structure with tables of powers of (jwk)^r or (zk^-r)
0030 %                            xMat.Plant        =    plant model, size: F x max order
0031 %
0032 %        ModelVar    =    contains the information about the model to be identified
0033 %                        structure with fields 'Transient', 'ThePlane', 'TheModel', 'Reciprocal', ...
0034 %                            ModelVar.Transient        =    1 then the initial conditions of the plant and/or noise are estimated
0035 %                            ModelVar.PlantPlane        =    plane of the plant
0036 %                            model
0037 %                                                            's':    continuous-time;
0038 %                                                            'w':    sqrt(s)-domain
0039 %                                                            'z':    discrete-time;
0040 %                                                            '':        plane not defined
0041 %                            ModelVar.RecipPlant        =    1 if plant model is reciprocal: G(i,j) = G(j,i)
0042 %                            ModelVar.nu                =    number of inputs
0043 %                            ModelVar.ny                =     number of outputs
0044 %                            ModelVar.na                =    order polynomial A
0045 %                            ModelVar.nb                =     order matrix polynomial B
0046 %                            ModelVar.nig            =    order vector polynomial Ig
0047 %
0048 %
0049 % Copyright (c) Rik Pintelon, Vrije Universiteit Brussel - dept. ELEC, 30 November 2009
0050 % All rights reserved.
0051 % Software can be used freely for non-commercial applications only.
0052 %
0053 
0054 % note that DC and Nyquist have a contribution 1/2 to the cost function
0055 % therefore the appropriate variables must be scaled by 1/sqrt(2) at DC
0056 % and Nyquist; this is already done for the variable Error
0057 
0058 
0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0060 % initialisation of the variables %
0061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0062 
0063 % number of frequencies
0064 F = size(xMat.Plant,1);
0065 
0066 % order polynomials
0067 na = ModelVar.na;
0068 nb = ModelVar.nb;
0069 nig = ModelVar.nig;
0070 
0071 % number of outputs and inputs
0072 ny = ModelVar.ny;
0073 nu = ModelVar.nu;
0074 
0075 % total number of model parameters
0076 ntheta = (na+1) + (nb+1)*nu*ny + (nig+1)*ny;
0077 
0078 % column covariance matrix of the jacobian of the output
0079 % equation error at one frequency
0080 TheCovJacob = zeros(ntheta, ntheta, F);
0081 
0082 % inverse weigthing matrix
0083 invW = Mat_Mult(data.sqrtWinv, data.sqrtWinv);
0084 
0085 
0086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0087 % Fast calculation of the derivative of vec(B) w.r.t. b. The lines below are equivalent with %
0088 % for kk = 1:F                                                                               %
0089 %     Deriv.vecBb(:,:,kk) = kron(eye(nu*ny, nu*ny), xMat.Plant(kk, 1:nb+1));                  %
0090 % end                                                                                        %
0091 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0092 
0093 Deriv_vecBb = zeros(ny*nu, ny*nu*(nb+1), F);
0094 for ii = 1:nu*ny
0095     
0096     vii = zeros(nu*ny, 1);
0097     vii(ii) = 1;
0098     Deriv_vecBb(ii,:,:) = kron(vii, (xMat.Plant(:, 1:nb+1)).');
0099     
0100 end % ii
0101 
0102 
0103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0104 % column covariance matrix w.r.t. a-parameters %
0105 %   a = Theta.A(:)                             %
0106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0107 
0108 % a-parameters
0109 na1 = na+1;
0110 for ii = 1:na1
0111     for jj = 1:ii
0112         TheCovJacob(ii,jj,:) = Mat_Trace(Mat_Mult(invW, data.CY)).* (conj(xMat.Plant(:,ii)) .* xMat.Plant(:,jj)).';
0113         if jj ~= ii
0114             TheCovJacob(jj,ii,:) = conj(TheCovJacob(ii,jj,:));
0115         end % if jj <> ii
0116     end % jj
0117 end % ii
0118 
0119 
0120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0121 % column covariance matrix w.r.t. b-parameters                %
0122 %   b = reshape(permute(Theta.B, [3,1,2]), [ny*nu*(nb+1),1])  %
0123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0124 
0125 % b-parameters
0126 nb1 = (nb+1)*nu*ny;
0127 for ii = 1:nb1
0128     ii1 = ii + na1;
0129     Mii = reshape(Deriv_vecBb(:,ii,:), [ny,nu,F]);
0130     for jj = 1:ii
0131         jj1 = jj + na1;
0132         Mjj = reshape(Deriv_vecBb(:,jj,:), [ny,nu,F]);
0133         TheCovJacob(ii1,jj1,:) = Mat_Trace(Mat_Mult(invW, Mat_Mult(Mjj, Mat_Mult(data.CU, Conj_Trans(Mii)))));
0134         if jj ~= ii
0135             TheCovJacob(jj1,ii1,:) = conj(TheCovJacob(ii1,jj1,:));
0136         end % if jj <> ii
0137     end % jj
0138 end % ii
0139 
0140 
0141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0142 % column covariance matrix w.r.t. mixed a,b-parameters        %
0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0144 
0145 % a,b-parameters
0146 for ii = 1:na1
0147     for jj = 1:nb1
0148         jj1 = jj + na1;
0149         Mjj = reshape(Deriv_vecBb(:,jj,:), [ny,nu,F]);
0150         TheCovJacob(ii,jj1,:) = -Mat_Trace(Mat_Mult(invW, Mat_Mult(Mjj, Conj_Trans(data.CYU)))).* (conj(xMat.Plant(:,ii))).';
0151         TheCovJacob(jj1,ii,:) = conj(TheCovJacob(ii,jj1,:));
0152     end % jj
0153 end % ii
0154 
0155 
0156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0157 % DC and Nyquist count for 1/sqrt(2) %
0158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0159 
0160 if data.DC == 1
0161     TheCovJacob(:,:,1) = TheCovJacob(:,:,1)/2;
0162 end
0163 if data.Nyquist == 1
0164     TheCovJacob(:,:,end) = TheCovJacob(:,:,end)/2;
0165 end

Generated on Thu 07-Jun-2012 11:58:58 by m2html © 2005