function [TheJacob, TheCovJacob] = MIMO_WGTLS_AddSelectColumns(TheJacob, TheCovJacob, TheSel, ModelVar); Imposes the common parameter structure (reciprocal) by adding the appropriate columns, and selects the columns of the Jacobian matrix corresponding to the parameters to be estimated Output parameter TheJacob = Jacobian matrix after imposing the common parameter structure, and selection of the parameters to be estimated size: ny * number of freq. x number of free model parameters TheCovJacob = column covariance matrix of the Jacobian matrix afer imposing the common parameter structure, and selection of the parameters to be estimated size: number of free model parameters x number of free model parameters Input parameter TheJacob = Jacobian matrix before imposing the common parameter structure: all parameters (even those who are zero) are free size: ny * F x ntheta TheCovJacob = column covariance matrix of the Jacobian matrix before imposing the common parameter structure: all parameters (even those who are zero) are free size: ntheta x ntheta TheSel = structure with fields 'A', 'B', 'Ig' TheSel = struct('A',[],'B',[], 'Ig', []) TheSel.A = 1 x (OrderA+1) TheSel.A(r) = 1 if coeff. a(r-1) is unknown Sel.A(r) = 0 if coeff. a(r-1) = 0 TheSel.B = ny x nu x (OrderB+1) TheSel.B(i,j,r) = 1 if coeff. b(i,j,r-1) is unknown TheSel.B(i,j,r) = 0 if coeff. b(i,j,r-1) = 0 TheSel.Ig = ny x (OrderIg+1) TheSel.Ig(i,r) = 1 if coeff. ig(i,r-1) is unknown TheSel.Ig(i,r) = 0 if coeff. ig(i,r-1) = 0 ModelVar = contains the information about the model to be identified ModelVar.Transient = 1 then the initial conditions of the plant are estimated ModelVar.PlantPlane = plane of the plant model 's': continuous-time; 'w': sqrt(s)-domain 'z': discrete-time; '': plane not defined ModelVar.Struct = model structure 'BJ': Box-Jenkins 'OE': output error (plant model only) 'ARMA': autoregressive moving average (noise model only) 'ARMAX': autoregressive moving average with exogenous input 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, 1 December 2009 All rights reserved. Software can be used freely for non-commercial applications only.
0001 function [TheJacob, TheCovJacob] = MIMO_WGTLS_AddSelectColumns(TheJacob, TheCovJacob, TheSel, ModelVar); 0002 % 0003 % function [TheJacob, TheCovJacob] = MIMO_WGTLS_AddSelectColumns(TheJacob, TheCovJacob, TheSel, ModelVar); 0004 % 0005 % Imposes the common parameter structure (reciprocal) by 0006 % adding the appropriate columns, and selects the columns of the 0007 % Jacobian matrix corresponding to the parameters to be estimated 0008 % 0009 % 0010 % Output parameter 0011 % 0012 % TheJacob = Jacobian matrix after imposing the common parameter structure, 0013 % and selection of the parameters to be estimated 0014 % size: ny * number of freq. x number of free model parameters 0015 % 0016 % TheCovJacob = column covariance matrix of the Jacobian matrix afer imposing the common 0017 % parameter structure, and selection of the parameters to be estimated 0018 % size: number of free model parameters x number of free model parameters 0019 % 0020 % 0021 % Input parameter 0022 % 0023 % TheJacob = Jacobian matrix before imposing the common parameter structure: 0024 % all parameters (even those who are zero) are free 0025 % size: ny * F x ntheta 0026 % 0027 % TheCovJacob = column covariance matrix of the Jacobian matrix before imposing the common parameter structure: 0028 % all parameters (even those who are zero) are free 0029 % size: ntheta x ntheta 0030 % 0031 % TheSel = structure with fields 'A', 'B', 'Ig' 0032 % TheSel = struct('A',[],'B',[], 'Ig', []) 0033 % TheSel.A = 1 x (OrderA+1) 0034 % TheSel.A(r) = 1 if coeff. a(r-1) is unknown 0035 % Sel.A(r) = 0 if coeff. a(r-1) = 0 0036 % TheSel.B = ny x nu x (OrderB+1) 0037 % TheSel.B(i,j,r) = 1 if coeff. b(i,j,r-1) is unknown 0038 % TheSel.B(i,j,r) = 0 if coeff. b(i,j,r-1) = 0 0039 % TheSel.Ig = ny x (OrderIg+1) 0040 % TheSel.Ig(i,r) = 1 if coeff. ig(i,r-1) is unknown 0041 % TheSel.Ig(i,r) = 0 if coeff. ig(i,r-1) = 0 0042 % 0043 % ModelVar = contains the information about the model to be identified 0044 % ModelVar.Transient = 1 then the initial conditions of the plant are estimated 0045 % ModelVar.PlantPlane = plane of the plant model 0046 % 's': continuous-time; 0047 % 'w': sqrt(s)-domain 0048 % 'z': discrete-time; 0049 % '': plane not defined 0050 % ModelVar.Struct = model structure 0051 % 'BJ': Box-Jenkins 0052 % 'OE': output error (plant model only) 0053 % 'ARMA': autoregressive moving average (noise model only) 0054 % 'ARMAX': autoregressive moving average with exogenous input 0055 % ModelVar.RecipPlant = 1 if plant model is reciprocal: G(i,j) = G(j,i) 0056 % ModelVar.nu = number of inputs 0057 % ModelVar.ny = number of outputs 0058 % ModelVar.na = order polynomial A 0059 % ModelVar.nb = order matrix polynomial B 0060 % ModelVar.nig = order vector polynomial Ig 0061 % 0062 % 0063 % Copyright (c) Rik Pintelon, Vrije Universiteit Brussel - dept. ELEC, 1 December 2009 0064 % All rights reserved. 0065 % Software can be used freely for non-commercial applications only. 0066 % 0067 0068 % order polynomials 0069 na = ModelVar.na; 0070 nb = ModelVar.nb; 0071 nig = ModelVar.nig; 0072 0073 % inputs and outputs 0074 nu = ModelVar.nu; 0075 ny = ModelVar.ny; 0076 0077 0078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0079 % in case of a reciprocal plant model structure % 0080 % - summing the appropriate columns Jacobian matrix % 0081 % - summing the appropriate columns and rows of column covariance matrix % 0082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0083 0084 if ModelVar.RecipPlant 0085 0086 start = (na+1) + 1; % ofset for coefficients A polynomial 0087 0088 for jj = 1:nu % column index 0089 for ii = 1+jj:ny % row index 0090 lij = ii + ny*(jj-1); % block position coefficients b(ii,jj) polynomial 0091 lji = jj + ny*(ii-1); % block position coefficients b(jj,ii) polynomial 0092 0093 if lji <= nu*ny % test for rectangular matrices 0094 startij = start + (lij-1)*(nb+1); 0095 stopij = start + lij*(nb+1) - 1 ; 0096 startji = start + (lji-1)*(nb+1); 0097 stopji = start + lji*(nb+1) - 1 ; 0098 TheJacob(:, startij:stopij) = TheJacob(:, startij:stopij) + TheJacob(:, startji:stopji); 0099 TheCovJacob(:, startij:stopij) = TheCovJacob(:, startij:stopij) + TheCovJacob(:, startji:stopji); 0100 TheCovJacob(startij:stopij, :) = TheCovJacob(startij:stopij, :) + TheCovJacob(startji:stopji, :); 0101 end % if 0102 0103 end % ii 0104 end % jj 0105 0106 end % if reciprocal plant model 0107 0108 0109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0110 % create row vector that selects the columns of the Jacobian % 0111 % matrix corresponding to the parameters to be estimated % 0112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0113 0114 % A polynomial 0115 Select = TheSel.A; 0116 0117 % B ny x nu matrix polynomial 0118 % for jj = 1:nu 0119 % for ii = 1:ny 0120 % Select = [Select, squeeze(TheSel.B(ii,jj,:)).']; 0121 % end % ii 0122 % end % jj 0123 SelB = permute(TheSel.B,[3, 1, 2]); % reason: vec(B) is calculated as: vecB = permute(B, [3, 1, 2]); vecB = vecB(:); 0124 Select = [Select, SelB(:).']; 0125 0126 % Ig ny x 1 vector polynomial 0127 % for ii = 1:ny 0128 % Select = [Select, TheSel.Ig(ii,:)]; 0129 % end % ii 0130 SelIg = TheSel.Ig.'; 0131 Select = [Select, SelIg(:).']; 0132 0133 0134 %%%%%%%%%%%%%%%%%%%%%%%%%%% 0135 % selection columns Jacob % 0136 %%%%%%%%%%%%%%%%%%%%%%%%%%% 0137 0138 TheJacob = TheJacob(:, Select == 1); 0139 0140 0141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0142 % selections columns and rows CovJacob % 0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0144 0145 TheCovJacob = TheCovJacob(Select == 1, Select == 1); 0146