function iduiqs
%IDUIQS Quickstart operation for ident.
%      For the current Estimation data set, the impulse response(s)
%      are calculated using correlation analysis. Then
%      the frequency response(s) are calculated using spectral
%      analysis. The delay in the different channels are
%      estimated by picking the first value where the impulse
%      response estimate exceeds 0.5*the estimated standard
%      deviation. Then a fourth order ARX-model is computed
%      with these delays. The step responses, the frequency
%      responses and a compare view are opened for the resulting
%      models

%   L. Ljung 4-4-94
%   Copyright 1986-2000 The MathWorks, Inc.
%   $Revision: 1.7 $  $Date: 2000/06/15 11:46:30 $

%global XIDplotw
 Xsum = findobj(get(0,'children'),'flat','tag','sitb16');
XID = get(Xsum,'Userdata');
dat =iduigetd('e');
[Ncap,ny,nu] = size(dat);%eval(info(4,:));
%nuseq=eval(['[',info(7,:),']']);
%nyseq=eval(['[',info(6,:),']']);
%if ~isempty(nuseq),nu1=nuseq(1);else nu1=0;end
%ny1=nyseq(1);
%[ny,nu]=iduiiono('old',info,'dat');
%chan_flag=0;
%if nu>0
%   if nu1>1|ny1>1,chan_flag=1;end
%else
%   if ny1>1,chan_flag=1;end
%end
if nu>0
   IR=iduinpar('cra');
   [IR1,Tim,sdIR] = impulse(IR);
   Ts = pvget(IR,'Ts');
   %IR1 = IR.ir;
  for ky=1:ny
     for ku=1:nu
        ir = squeeze(IR1(:,ky,ku));
        lev = squeeze(sdIR(:,ky,ku));
     kdum=find(abs(ir)-lev*2.58>0);
     if isempty(kdum)
        nk(ky,ku)=0;
     else
        nk(ky,ku)=floor(max(0,Tim(kdum(1))/Ts));  
     end
   end
  end
  set(XID.plotw(5,2),'value',1),iduipw(5);
  %if chan_flag,iduiiono('update',ny1,nu1,5,1);end
end
iduinpar('spa');
if nu>0,
  wino=2;
else
  wino=7;
end
set(XID.plotw(wino,2),'value',1),iduipw(wino);
%if chan_flag,iduiiono('update',ny1,nu1,wino,1);end
iduistat('Computing a 4th order ARX model...');
if nu==0,nk=zeros(ny,nu);end
iduiarx('estimate',[4*ones(ny,ny),4*ones(ny,nu),nk],'arxqs');
set(XID.plotw(3,2),'value',1),iduipw(3);
%if ny1>1,iduiiono('update',ny1,nu1,3,1);end
if Ncap>19*ny+30*(nu+1)
  iduistat('Computing a default order state space model using N4SID...');
  iduiss('qsestimate');
else
  iduistat('Too few data points for default order N4SID model.')
end
