diff scripts/control/stepimp.m @ 3381:69b167451491

[project @ 1999-12-15 20:48:10 by jwe]
author jwe
date Wed, 15 Dec 1999 20:48:45 +0000
parents 8dd4718801fd
children 10f21f7ccc7f
line wrap: on
line diff
--- a/scripts/control/stepimp.m
+++ b/scripts/control/stepimp.m
@@ -1,20 +1,20 @@
-# Copyright (C) 1996,1998 Auburn University.  All Rights Reserved.
-#
-# This file is part of Octave. 
-#
-# Octave is free software; you can redistribute it and/or modify it 
-# under the terms of the GNU General Public License as published by the 
-# Free Software Foundation; either version 2, or (at your option) any 
-# later version. 
-# 
-# Octave is distributed in the hope that it will be useful, but WITHOUT 
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
-# for more details.
-# 
-# You should have received a copy of the GNU General Public License 
-# along with Octave; see the file COPYING.  If not, write to the Free 
-# Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. 
+## Copyright (C) 1996,1998 Auburn University.  All Rights Reserved.
+##
+## This file is part of Octave. 
+##
+## Octave is free software; you can redistribute it and/or modify it 
+## under the terms of the GNU General Public License as published by the 
+## Free Software Foundation; either version 2, or (at your option) any 
+## later version. 
+## 
+## Octave is distributed in the hope that it will be useful, but WITHOUT 
+## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
+## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
+## for more details.
+## 
+## You should have received a copy of the GNU General Public License 
+## along with Octave; see the file COPYING.  If not, write to the Free 
+## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. 
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File } {[y, t] = } stepimp(@var{sitype},@var{sys}[, @var{inp}, @var{tstop}, @var{n}]) 
@@ -29,12 +29,13 @@
 ## or @code{impulse} instead.
 ## 
 ## @end deftypefn
-##  
-## ## See also: step, impulse
+
+## See also: step, impulse
 
 function [y, t] = stepimp(sitype, sys, inp, tstop, n)
-# Written by Kai P. Mueller October 2, 1997
-# based on lsim.m of Scottedward Hodel
+
+  ## Written by Kai P. Mueller October 2, 1997
+  ## based on lsim.m of Scottedward Hodel
 
   if (sitype == 1)         IMPULSE = 0;
   elseif (sitype == 2)     IMPULSE = 1;
@@ -47,7 +48,7 @@
   N_MAX = 2000;  # maximum number of points
   T_DEF = 10.0;  # default simulation time
 
-  # collect useful information about the system
+  ## collect useful information about the system
   [ncstates,ndstates,NIN,NOUT] = sysdimensions(sys);
   TSAMPLE = sysgettsam(sys);
 
@@ -66,11 +67,11 @@
     error("step: pure gain block (n_states < 1), step response is trivial");
   endif
   if (nargin < 5)
-    # we have to compute the time when the system reaches steady state
-    # and the step size
+    ## we have to compute the time when the system reaches steady state
+    ## and the step size
     ev = eig(sys2ss(sys));
     if (DIGITAL)
-      # perform bilinear transformation on poles in z
+      ## perform bilinear transformation on poles in z
       for i = 1:NSTATES
         pole = ev(i);
 	if (abs(pole + 1) < 1.0e-10)
@@ -80,7 +81,7 @@
 	endif
       endfor
     endif
-    # remove poles near zero from eigenvalue array ev
+    ## remove poles near zero from eigenvalue array ev
     nk = NSTATES;
     for i = 1:NSTATES
       if (abs(ev(i)) < 1.0e-10)
@@ -90,23 +91,23 @@
     endfor
     if (nk == 0)
       USE_DEF = 1;
-      #printf("##STEPIMP-DEBUG: using defaults.\n");
+      ## printf("##STEPIMP-DEBUG: using defaults.\n");
     else
       ev = ev(find(ev));
       x = max(abs(ev));
       t_step = 0.2 * pi / x;
       x = min(abs(real(ev)));
       t_sim = 5.0 / x;
-      # round up
+      ## round up
       yy = 10^(ceil(log10(t_sim)) - 1);
       t_sim = yy * ceil(t_sim / yy);
-      #printf("##STEPIMP-DEBUG: nk=%d   t_step=%f  t_sim=%f\n",
-      #       nk, t_step, t_sim);  
+      ## printf("##STEPIMP-DEBUG: nk=%d   t_step=%f  t_sim=%f\n",
+      ##   nk, t_step, t_sim);  
     endif
   endif
 
   if (DIGITAL)
-    # ---- sampled system
+    ## ---- sampled system
     if (nargin == 5)
       n = round(n);
       if (n < 2)
@@ -114,9 +115,9 @@
       endif
     else
       if (nargin == 4)
-        # n is unknown
+        ## n is unknown
       elseif (nargin >= 1)
-        # tstop and n are unknown
+        ## tstop and n are unknown
         if (USE_DEF)
           tstop = (N_MIN - 1) * TSAMPLE;
         else
@@ -135,7 +136,7 @@
     tstop = (n - 1) * TSAMPLE;
     t_step = TSAMPLE;
   else
-    # ---- continuous system
+    ## ---- continuous system
     if (nargin == 5)
       n = round(n);
       if (n < 2)
@@ -144,7 +145,7 @@
       t_step = tstop / (n - 1);
     else
       if (nargin == 4)
-        # only n in unknown
+        ## only n in unknown
         if (USE_DEF)
           n = N_MIN;
 	  t_step = tstop / (n - 1);
@@ -152,7 +153,7 @@
           n = floor(tstop / t_step) + 1;
         endif
       else
-        # tstop and n are unknown
+        ## tstop and n are unknown
         if (USE_DEF)
           tstop = T_DEF;
 	  n = N_MIN;
@@ -177,7 +178,7 @@
     B = B(:,inp);
     sys = c2d(sys, t_step);
   endif
-  #printf("##STEPIMP-DEBUG: t_step=%f n=%d  tstop=%f\n", t_step, n, tstop);
+  ## printf("##STEPIMP-DEBUG: t_step=%f n=%d  tstop=%f\n", t_step, n, tstop);
 
   F = sys.a;
   G = sys.b(:,inp);
@@ -211,7 +212,7 @@
   endif
 
   if(nargout == 0)
-    # Plot the information
+    ## Plot the information
     oneplot();
     gset nogrid
     gset nologscale
@@ -257,10 +258,10 @@
 	  plot(t, yy);
 	endif
       endfor
-      # leave gnuplot in multiplot mode is bad style
+      ## leave gnuplot in multiplot mode is bad style
       oneplot();
     else
-      # plot everything in one diagram
+      ## plot everything in one diagram
       title([tt, " response | ", sysgetsignals(sys,"in",inp,1), ...
 	" -> all outputs"]);
       if (DIGITAL)
@@ -275,5 +276,5 @@
     y=[];
     t=[];
   endif
-  #printf("##STEPIMP-DEBUG: gratulations, successfull completion.\n");
+  ## printf("##STEPIMP-DEBUG: gratulations, successfull completion.\n");
 endfunction