⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 misfit.m

📁 The main features of the considered identification problem are that there is no an a priori separati
💻 M
字号:
function [ M, w, xini ] = misfit( w, sys, exct )% MISFIT - Global Total Least Squares misfit ||W - Wh||_F. % % [ M, wh, xini ] = misfit( w, sys, exct )% % Inputs:% W    - given time series (#samples x #variables x #time series).% SYS  - state-space system with M inputs, P:=size(W,2)-M outputs, %        and order N:=L*P, where L is an integer.% EXCT - vector of indices for exact variables (default []).%% Outputs:% M    - misfit ||W - WH||_F.% WH   - optimal approximating time series.% XINI - initial condition, under which WH is obtained.% Author: Ivan Markovsky, Date: November 2004 % Reference: I. Markovsky, J. C. Willems, S. Van Huffel, % B. De Moor, and R. Pintelon, "Application of structured total % least squares for system identification and model reduction", % Report 04--51, Dept. EE, K.U. Leuven, 2004% ConstantsT     = size(w,1); % # of samplesnw    = size(w,2); % # of variablesk     = size(w,3); % # of time series[p,m] = size(sys);n     = size(sys,'order');l     = n/p;l1    = l + 1;% Check for parameters out of rangeif nargin < 2  error('Not enough input arguments. (W and SYS should be given.)')endif (~isreal(w))  error('Complex data not supported.')endif nargin == 2 | isempty(exct)  exct = [];elseif any(1 > exct | nw < exct)  error('An index for exact variable is out of range.')elseif m == 0  error('The output only case can not have exact variables.')end% Check SYSif ~isa(sys,'ss')  error('SYS not an SS object.')endif (m+p ~= nw)  error('#inputs + #output of SYS not equal to size(W,2).')endif (ceil(l)-l ~=  0)  error('SYS not of order that is a multiple of #outputs.')end% Structure specificationnoisy = 1:nw; % indices of noisy variablesif m > 0  ne = length(exct);  nn = nw - ne;  noisy(exct) = []; % indices of noisy variables  if ne == 0    struct = [2 nw*l1 nw];    h = blkhankel(w,l1)';   else % define a block of exact variables    struct = [4 ne*l1 ne; 2 nn*l1 nn];     h = [blkhankel(w(:,exct,:),l1); blkhankel(w(:,noisy,:),l1)]';  endelse % Output only case (generically can not have exact variables)  struct = [2 p*l1 p];  h = blkhankel(w,l1)';     endif k > 1  struct.a = struct;  struct.k = k;end  % Convert (A,B,C,D) to a parameter X for STLS x = sys2x(sys, exct, noisy);% STLS cost function evaluationif nargout > 1  [M,dp] = stls_cost_fun(x,h,struct);else % WH not needed  M = stls_cost_fun(x,h,struct);endM = sqrt(M);clear h% Find the corrected trajectoryif nargout > 1  if m > 0 % Input-Output case    if k == 1      dwn = reshape(dp,nn,T)';    else % k > 1      dwn = shiftdim(reshape(dp,nn,k,T),2);    end    w(:,noisy,:) = w(:,noisy,:) - dwn;  else % Output only case    if k == 1      dw = reshape(dp,p,T)';    else % k > 1      dw = shiftdim(reshape(dp,p,k,T),2);        end    w = w - dw;  end  % Find the initial condition  if nargout > 2    xini = inistate(w,sys);  end  end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -