www.pudn.com > Closid30.rar > Clmodqs.m, change:1998-09-16,size:2287b


function clmodqs(option) 
 
% function clmodqs(option) 
% 
% Performs a quick-start identification of an auxiliary object 
% in the first step of the closed-loop identification methods  
% for which this step is nontrivial. 
% Two-step method:           option=1   identified object: S or CS 
% Coprime factor method:     option=2	identified object: Gx = Nx/Dx 
% Dual-Youla identification: option=3   identified object: Gx = Nx/Dx 
% The output information is stored as an auxiliary model(option 1)  
% or as an auxiliary model factorization (option 2,3). 
 
% Functions called: arx,arxtsruc,selstruc,clobjget,clsplit, 
%                   cldn2sys,th2ss,minreal,cldncf,clobjins 
 
% 01-11-1996 
% (c) Paul Van den Hof 
% Mechanical Engineering Systems and Control Group 
% Delft University of Technology 
% Last update: 07-06-1997. 
%              11-09-1998. Adapted to deal with working data. 
%              16-09-1998  datc --> datre 
 
% Take the excitation signal that is stored in 'datre' as a basis for the 
% quick start identification: 
 
r_c=clobjget('datre'); 
data=clobjget('datw'); 
 
if option==2 | option==3 
  y=data(:,[2 1]); 
else 
  y=data(:,2); 
end 
% 
%Fix maximum order of model to be identified 
if option==1 
  n=20;     % Two-step 
elseif option==3 
  n=5;		%  dual-Y 
else 
  n=8;		% Copfac  
end 
nn=[[1:n]' [2:n+1]' zeros(n,1)]; 
% 
% Split data set in identification and validation part: 
N=size(y,1); 
Ne=round(0.6*N); 
% 
% Perform order test 
% (For Coprime factor and dual-Youla method de order test  
%  is only based on the transfer r_c --> y). 
V=arxstruc([y(1:Ne,1) r_c(1:Ne)],[y(Ne+1:N,1) r_c(Ne+1:N)],nn); 
nn=selstruc(V,'AIC'); 
% 
% Construct correct model order: 
if option==1 
  nnm=nn; 
else  		  % two-output situation 
  nnm=[nn(1)*ones(2,2) nn(2)*ones(2,1) zeros(2,1)]; 
end 
% 
% Identify ARX model: 
thqs=arx([y r_c],nnm); 
 
[a,b,c,d]=th2ss(thqs); 
[a,b,c,d]=minreal(a,b,c,d); 
if option==1 
  clobjins([a b;c d],'X'); 
else 
  [sx,nsx]=cldn2sys([a b;c d],length(a),'r'); 
  [ax,bx,cx,dx]=clsplit(sx,nsx); 
  [ax,bx,cx,dx]=minreal(ax,bx,cx,dx); 
  sx=[ax bx;cx dx]; 
  Xf=cldncf(sx,length(ax),'R'); 
  clobjins(Xf,'Xnd'); 
  if option==3 
	C=clobjget('C'); 
	nc=length(C)-1; 
	Cf=cldncf(C,nc,'R'); 
	clobjins(Cf,'Cnd'); 
  end 
end