home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / languages / rlab1_23a / CTB / timeplot < prev    next >
Text File  |  1995-11-14  |  2KB  |  76 lines

  1.  
  2. //-----------------------------------------------------------------------
  3. //
  4. // timeplot
  5. //
  6. // Syntax: timeplot(iy,iu,f,ntim,Y);
  7. //
  8. // This routine plot the time response data in the block data
  9. // matrix Y. The inputs are:
  10. //
  11. //    iy, iu -- Output number and input number to plot
  12. //    f -- Data sample rate
  13. //    ntim -- Number of time blockes stored in Y
  14. //    Y -- Block-storage data matrices
  15. //    name1,name2 -- Annotation labels for the plots
  16. //
  17. //
  18. // Originally written by Lee D. Peterson for MATLAB
  19. // Modified and ported to RLaB be Jeffrey B. Layton
  20. // Version JBL 940519
  21. //-----------------------------------------------------------------------
  22.  
  23. timeplot = function(iy,iu,f,ntim,Y,name)
  24. {
  25.    local(m,l,t,yindex,nargs,strout)
  26.  
  27. // Count number of input arguments
  28.    nargs=0;
  29.    if (exist(iy)) {nargs=nargs+1;}
  30.    if (exist(iu)) {nargs=nargs+1;}
  31.    if (exist(f)) {nargs=nargs+1;}
  32.    if (exist(ntim)) {nargs=nargs+1;}
  33.    if (exist(Y)) {nargs=nargs+1;}
  34.    if (exist(name)) {nargs=nargs+1;}
  35.  
  36.    if (nargs != 6) {
  37.        error("timeplot: Wrong number of input arguments");
  38.    }
  39.  
  40. // Get the sizes of the blocks in Y
  41.    m=Y.nc;
  42.    l=Y.nr/ntim;
  43.    if (fix(l) != l) {
  44.        error("Y dimension is not an even multiplier of given ntim.");
  45.    }
  46.  
  47. // Check the input / output designators
  48.    printf("iy = %i \n",iy);
  49.    printf("iu = %i \n",iu);
  50.    printf("name = %s \n",name);
  51.    if ( (iy < 0) || (iy > l) || (iu < 0) || (iu > m) ) {
  52.        error("Selected plot is out-of-bounds.");
  53.    }
  54.  
  55. // Set-up the time axis vector
  56.    t=[0:(ntim-1)/f:1/f]';
  57.  
  58. // Label the axes
  59.    xlabel("t (seconds)");
  60.  
  61. // Title the plot
  62.    strout="Response y"+int2str(iy)+" to Input u"+int2str(iu);
  63.    printf("%s",strout);
  64.    printf("%s"," \n");
  65.    ptitle(strout);
  66.  
  67. // Label the data
  68.    plegend(name);
  69.  
  70. // Make the plot
  71.    yindex=iy:l*ntim:l;
  72.  
  73.    plot([t,Y[yindex;iu]]);
  74.  
  75. };
  76.