home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / EXRESP.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  987 b   |  38 lines

  1. function exresp(fun,ssflag) 
  2. %EXRESP Example response, used by plotting control routines to give
  3. %       an example or their use.
  4. %    EXRESP('fun')
  5. %    EXRESP('fun',ssflag)
  6.  
  7. %    Andrew Grace  7-9-90
  8. %    Revised ACWG 6-21-92
  9. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  10.  
  11. if nargin==1, ssflag = 0; end
  12.  
  13. order=round(abs(randn(1,1))*5+2);
  14. disp('')
  15. disp([' Here is an example of how the function ', fun, ' works'])
  16. disp('')
  17. disp(' Consider a randomly generated stable Transfer Function Model:')
  18. if fun(1)=='d'
  19.   disp(' of the form G(z)=num(z)/den(z):')
  20.   [num,den]=drmodel(order)
  21. else
  22.   disp(' of the form G(s)=num(s)/den(s):')
  23.   [num,den]=rmodel(order)
  24. end
  25. if ssflag, 
  26.   disp('Transform to state space with: [a,b,c,d] = tf2ss(num,den);');
  27.   [a,b,c,d] = tf2ss(num,den);
  28.   call=[fun,'(a,b,c,d);'];
  29. else
  30.   call=[fun,'(num,den);'];
  31. end
  32. disp('')
  33. disp(['Call ', fun, ' using the following command (see also, help ',fun,'):'])
  34. disp('')
  35. disp(call)
  36. disp('')
  37. eval(call)
  38.