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

  1. function G=trfcont(th,nnu,w)
  2. %TRFCONT Computes the continuous time transfer function of a model.
  3. %    A recommended newer variant to use is TH2FF(THD2THC(TH))
  4. %    G = trfcont(TH)
  5. %
  6. %    TH: A matrix defining a model, as described in HELP THETA
  7. %
  8. %    G is returned as the transfer function of a continous time counter-
  9. %    part of the model TH. This functions is of the standard frequency
  10. %    function format (see HELP FREQFUNC). Note that no automatic compu-
  11. %    tation of the noise spectrum is offered.
  12. %    
  13. %    If the model TH has several inputs, G will be returned as the transfer
  14. %    functions of selected inputs # j1 j2 .. jk by 
  15. %    G = trfcont(TH,[j1 j2 ... jk])  [default is all inputs]
  16. %    The functions are computed at 128 logathmically spaced frequency-values
  17. %    going about a decade above the Nyquist frequency. The functions can be
  18. %    computed at arbitrary frequencies w (a row vector, generated e.g. by 
  19. %    LOGSPACE) by G = trfcont(TH,ku,w).
  20. %    The transfer function can be plotted by BODEPLOT. bodeplot(trfcont(TH))
  21. %    is a possible construction.
  22. %    See also TRF and TRFSD.
  23.  
  24. %    L. Ljung 7-7-87
  25. %    Copyright (c) 1987 by the MathWorks, Inc.
  26. %    All Rights Reserved.
  27.  
  28. T=th(1,2); nu=th(1,3);
  29.  
  30. % *** Set up default values ***
  31. wdef=logspace(log10(pi/T/100),log10(10*pi/T),128);
  32. if nargin<3, w=wdef;,end
  33. if nargin<2 , nnu=1:th(1,3);end
  34. if length(w)==1, if w<0, w=wdef;end,end
  35. if length(nnu)==1, if nnu<0, nnu=1:th(1,3);end,end
  36.  
  37. %  *** Transform to continuous time (remove delays)***
  38.  
  39. [bc,fc]=contin(th,nnu,1);
  40.  
  41. nk=th(1,2*nu+7:3*nu+6);   % The delays
  42.  
  43. [nrb,ncb]=size(bc);[nrf,ncf]=size(fc);
  44. nm=max(ncb,ncf);
  45.    i=sqrt(-1);
  46.  
  47.  
  48. % *** Compute the transfer function(s) GC=bc/fc ***
  49. nrc=length(w)+1;
  50. sc=1;
  51. for k=nnu
  52.     G(1,sc:sc+2)=[100+k,k,20+k];    
  53.     G(2:nrc,sc)=w';
  54.     GC=polyval(bc(k,:),i*w)./polyval(fc(k,:),i*w);
  55.     G(2:nrc,sc+1)=abs(GC');
  56.     G(2:nrc,sc+2)=(phase(GC)'-w'*T*max(0,(nk(k)-1)))*180/pi; % Add the delays
  57.     sc=sc+3;
  58. end
  59.  
  60.