home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 9.ddi / IDENT.DI$ / SEARCH.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.5 KB  |  51 lines

  1. function [TH,st]=search(z,th,g,lim)
  2. %SEARCH   Searches for a lower value of the criterion function
  3. %
  4. %    [TH,ST] = search(Z,TH,G,LIM)
  5. %
  6. %    TH : New parameter giving a lower value of the criterion
  7. %    ST=1 : No lower value of the criterion could be found.
  8. %
  9. %    The routine evaluates the prediction error criterion at values
  10. %    along the G-direction, starting at TH. It is primarily intended
  11. %    as a subroutine to MINCRIT. See PEM for an explanation of the
  12. %    arguments.
  13.  
  14. %    L. Ljung 10-1-86
  15. %    Copyright (c) 1986 by the MathWorks, Inc.
  16. %    All Rights Reserved.
  17.  
  18. % *** Set up the model orders ***
  19.  
  20. th1=th;nu=th(1,3);
  21. Nb=sum(th(1,4:4+nu)); nc=th(1,5+nu); Nd=sum(th(1,4:6+nu));
  22. nf=th(1,7+nu:6+2*nu);
  23. n=sum(th(1,4:6+2*nu));
  24. l=0;,k=1;,V=th(1,1);,V1=V+1;st=0;
  25.  
  26. % *** Looping, attempting to find a lower value of V along
  27. %     the G-direction ***
  28.  
  29. while [V1 > V l<10],
  30.    th(3,1:n)=th1(3,1:n)+k*g';mc=0;
  31.    if nc>0,c=fstab([1 th(3,Nb+1:Nb+nc)]); th(3,Nb+1:Nb+nc)=c(2:nc+1);
  32.        else c=1;end
  33.    s=Nd;
  34.    for ku=1:nu, 
  35.       if nf(ku)>0,  f=fstab([1 th(3,s+1:s+nf(ku))]);
  36.       th(3,s+1:s+nf(ku))=f(2:1+nf(ku));end
  37.         s=s+nf(ku);
  38.    end
  39.    
  40.       e=pe(z,th);
  41.       [me,ne]=size(e);
  42.       ll=lim*ones(me,ne);,el=min(e,ll);,el=max(el,-ll);
  43.       V1=e'*el/length(e);
  44.    
  45.    home, disp(int2str(l)) % Give status information to the screen
  46.    k=k/2; if l==8,k=0;end
  47.    l=l+1; if l==10, st=1;end
  48. end
  49.  
  50. TH=th;,TH(1,1)=V1;if length(e)>1, TH(2,1)=e'*e/length(e);end
  51.