TheError = MIMO_ML_PredError(data, PolyTrans) Output parameters TheError = prediction error model equations, size ny x F TheError = CY^(-1/2) * (Y - G * U - Tg) 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 Y, size: ny x ny x F data.CU = (sample) noise covariance matrix of U, size: nu x nu x F data.CYU = (sample) noise covariance matrix of U, size: ny x nu x F data.sqrtCYinv = CY^(-0.5), size: ny x ny x F data.DC = 1 if DC present otherwise 0 data.Nyquist = 1 if Nyquist frequency present otherwise 0 PolyTrans = structure containing the polynomials and transfer functions evaluated in x PolyTrans.A = denominator polynomial plant transfer function evaluated in x.Plant size 1 x F PolyTrans.G = plant transfer matrix evaluated in x.Plant size ny x nu x F PolyTrans.Tg = plant transient term evaluated in x.Plant size ny x F PolyTrans.sqrtCEinv = hermitian symmetric square root of the inverse of the covariance of the output error (Cov(NY-G*NU)) Copyright (c) Rik Pintelon, Vrije Universiteit Brussel - dept. ELEC, November 2009 All rights reserved. Software can be used freely for non-commercial applications only.
0001 function TheError = MIMO_ML_PredError(data, PolyTrans); 0002 % 0003 % TheError = MIMO_ML_PredError(data, PolyTrans) 0004 % 0005 % Output parameters 0006 % 0007 % TheError = prediction error model equations, size ny x F 0008 % TheError = CY^(-1/2) * (Y - G * U - Tg) 0009 % 0010 % Input parameters 0011 % 0012 % data = structure containing the non-parametric data 0013 % data.Y = DFT spectrum ny x 1 output signal, size: ny x F 0014 % data.U = DFT spectrum nu x 1 input signal, size: nu x F 0015 % data.freq = vector of frequency values (Hz), size: F x 1 0016 % data.Ts = sampling time (s) 0017 % data.CY = (sample) noise covariance matrix of Y, size: ny x ny x F 0018 % data.CU = (sample) noise covariance matrix of U, size: nu x nu x F 0019 % data.CYU = (sample) noise covariance matrix of U, size: ny x nu x F 0020 % data.sqrtCYinv = CY^(-0.5), size: ny x ny x F 0021 % data.DC = 1 if DC present otherwise 0 0022 % data.Nyquist = 1 if Nyquist frequency present otherwise 0 0023 % 0024 % PolyTrans = structure containing the polynomials and transfer functions evaluated in x 0025 % PolyTrans.A = denominator polynomial plant transfer function evaluated in x.Plant 0026 % size 1 x F 0027 % PolyTrans.G = plant transfer matrix evaluated in x.Plant 0028 % size ny x nu x F 0029 % PolyTrans.Tg = plant transient term evaluated in x.Plant 0030 % size ny x F 0031 % PolyTrans.sqrtCEinv = hermitian symmetric square root of the inverse of the covariance of the 0032 % output error (Cov(NY-G*NU)) 0033 % 0034 % 0035 % Copyright (c) Rik Pintelon, Vrije Universiteit Brussel - dept. ELEC, November 2009 0036 % All rights reserved. 0037 % Software can be used freely for non-commercial applications only. 0038 % 0039 0040 ny = size(data.Y, 1); % number of outputs 0041 nu = size(data.U, 1); % number of outputs 0042 F = size(data.Y, 2); % number of frequencies 0043 Y = data.Y; 0044 U = data.U; 0045 G = PolyTrans.G; 0046 0047 sqrtCEinv = PolyTrans.sqrtCEinv; 0048 0049 Tg = PolyTrans.Tg; 0050 0051 TheError = zeros(ny, F); 0052 0053 0054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0055 % Fast calculation of the prediction error TheError: the lines below are equivalent with % 0056 % for kk = 1:F % 0057 % TheError(:, kk) = sqrtCEinv(:, :, kk)*(Y(:, kk) - G(:, :, kk)*U(:, kk) - Tg(:, kk)); % 0058 % end % 0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0060 0061 UT = zeros(1, nu, F); 0062 UT(1,:,:) = U; 0063 GU = sum(G.*repmat(UT, ny, 1), 2); 0064 [rows, columns, depth] = size(GU); 0065 GU = squeeze(GU); 0066 % squeeze function on 1 x 1 x F delivers F x 1 !!! 0067 if rows*columns == 1 0068 GU = GU.'; 0069 end 0070 E = Y - GU - Tg; 0071 ET = zeros(1, ny, F); 0072 ET(1,:,:) = E; 0073 TheError = sum(sqrtCEinv.*repmat(ET, ny, 1), 2); 0074 [rows, columns, depth] = size(TheError); 0075 TheError = squeeze(TheError); 0076 % squeeze function on 1 x 1 x F delivers F x 1 !!! 0077 if rows*columns == 1 0078 TheError = TheError.'; 0079 end 0080 0081 0082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0083 % DC and Nyquist have half of the weight in the ML cost function % 0084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0085 0086 if data.DC == 1 0087 TheError(:, 1) = TheError(:, 1)/sqrt(2); 0088 end % if DC 0089 0090 if data.Nyquist == 1 0091 TheError(:, end) = TheError(:, end)/sqrt(2); 0092 end % if Nyquist