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

📄 compare.m

📁 剑桥大学用于线性和双线性动力学系统辨识的工具箱
💻 M
字号:
function [y,fit] = compare(model,data,INIT)%BILIN/COMPARE    Compares simulated output data with the measured data.%%   [YH,FIT] = compare(M,DATA)%   [YH,FIT] = compare(M,DATA,INIT)%%   M is the bilinear model as a BILIN object and DATA is the input-output%   data, given as an IDDATA object.%%   The argument INIT determines how to deal with initial conditions:%     - INIT = 'estimate' results in the initial state being chosen so%         that the norm of the prediction error is minimized (default).%     - INIT = 'model' uses M.X0 as the initial state.%     - INIT = 'zero' sets the initial state to zero.%     - if INIT is a column vector, then INIT is used as the initial state. %%   YH is the resulting simulated/predicted output returned as an IDDATA%   object. FIT is an optional output vector containing the percentage of%   the measured output that is explained by the model, with FIT(1) being%   the percentage fit of the first output, etc.%%   In the absence of output arguments, compare(M,DATA) outputs the%   percentage fit to the workspace and produces plots comparing the%   measured and simulated outputs.%%   See also BILIN, BILIN/SIM, BILIN/PE, IDDATA, IDDATA/PLOT.%% CUED System Identification Toolbox.% Cambridge University Engineering Department.% Copyright (C) 1998-2002. All Rights Reserved.% Version 1.00, Date: 01/06/2002% Created by H. Chen and E.C. Kerrigan.if nargin <= 1 | nargin >= 4  error('Incorrect number of input arguments.')endif nargin == 3  if isempty(INIT)	[E,X0] = pe(model,data,'estimate');  else	n = size(model.A,1);	if isa(INIT,'char')	  switch lower(INIT)	   case {'z','zero'}		X0 = zeros(n,1);	   case {'m','model'}		X0 =  model.X0;	   case {'e','estimate'}		[E,X0] = pe(model,data,INIT);	   otherwise		error('Invalid choice for INIT.')	  end	elseif isa(INIT,'numeric')	  X0 = INIT;	  if size(X0,1) ~= n | size(X0,2) ~= 1		error('X0 should be an n-dimensional column vector.')	  end	else	  error('Invalid choice for INIT.')	end  endelse  [E,X0] = pe(model,data,'estimate');end[y,x,yu] = sim(model,data,X0);deviation = y.y;p = size(deviation,2);fit = zeros(p,1);for i = 1:p  deviation(:,i)  = deviation(:,i)-mean(y.y(:,i));  fit(i) = 100*(1-norm(data.y(:,i)-y.y(:,i))/norm(deviation));endif nargout == 0  disp(' ')  disp('Percentage Fit:')    for i = 1:p	disp(sprintf('   %s - %0.4g%%',data.OutputName{i},fit(i)))  end  disp(' ')  for i = 1:p	plot(data(:,i,[]),yu(:,i,[]))	legend('Measured Output',sprintf('Simulated Fit: %0.4g%%',fit(i)))	if i < p	  pause	end  end  clear y fitend% *** last line of compare.m ***

⌨️ 快捷键说明

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