changeset 3679:0f319a2fca12

[project @ 2000-06-08 16:17:42 by jwe]
author jwe
date Thu, 08 Jun 2000 16:17:42 +0000
parents b6cc5bcfba8f
children b8b0f5ff28e2
files scripts/ChangeLog scripts/control/base/__stepimp__.m
diffstat 2 files changed, 75 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,9 @@
+2000-06-08  Ben Sapp <bsapp@nua.lampf.lanl.gov>
+
+	* control/base/__stepimp__.m: Reset multiplot state when done.
+	Do the right thing even if automatic_replot is not zero.
+	Avoid failure if system has pure imaginary poles.
+
 2000-06-06  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* general/logical.m: Return arg if it is empty.  Better error
--- a/scripts/control/base/__stepimp__.m
+++ b/scripts/control/base/__stepimp__.m
@@ -83,7 +83,7 @@
     ## remove poles near zero from eigenvalue array ev
     nk = NSTATES;
     for i = 1:NSTATES
-      if (abs(ev(i)) < 1.0e-10)
+      if (abs(real(ev(i))) < 1.0e-10)
         ev(i) = 0;
         nk = nk - 1;
       endif
@@ -209,71 +209,77 @@
       x = F * x + G;
     endfor
   endif
-
-  if(nargout == 0)
-    ## Plot the information
-    oneplot();
-    gset nogrid
-    gset nologscale
-    gset autoscale
-    gset nokey
-    clearplot();
-    if (gnuplot_has_multiplot)
-      if (IMPULSE)
-        gm = zeros(NOUT, 1);
-        tt = "impulse";
+  
+  save_automatic_replot = automatic_replot;
+  unwind_protect
+    automatic_replot = 0;
+    if(nargout == 0)
+      ## Plot the information
+      oneplot();
+      gset nogrid
+      gset nologscale
+      gset autoscale
+      gset nokey
+      clearplot();
+      if (gnuplot_has_multiplot)
+	if (IMPULSE)
+          gm = zeros(NOUT, 1);
+          tt = "impulse";
+	else
+          ssys = ss2sys(F, G, C, D, t_step);
+          gm = dcgain(ssys);
+          tt = "step";
+	endif
+	ncols = floor(sqrt(NOUT));
+	nrows = ceil(NOUT / ncols);
+	for i = 1:NOUT
+          subplot(nrows, ncols, i);
+          title(sprintf("%s: | %s -> %s", tt,sysgetsignals(sys,"in",inp,1), ...
+			sysgetsignals(sys,"out",i,1)));
+          if (DIGITAL)
+            [ts, ys] = stairs(t, y(i,:));
+            ts = ts(1:2*n-2)';  ys = ys(1:2*n-2)';
+            if (length(gm) > 0)
+              yy = [ys; gm(i)*ones(size(ts))];
+            else
+              yy = ys;
+            endif
+            grid("on");
+            xlabel("time [s]");
+            ylabel("y(t)");
+            plot(ts, yy);
+          else
+            if (length(gm) > 0)
+              yy = [y(i,:); gm(i)*ones(size(t))];
+            else
+              yy = y(i,:);
+            endif
+            grid("on");
+            xlabel("time [s]");
+            ylabel("y(t)");
+            plot(t, yy);
+          endif
+	endfor
+	## leave gnuplot in multiplot mode is bad style
+	oneplot();
       else
-        ssys = ss2sys(F, G, C, D, t_step);
-        gm = dcgain(ssys);
-        tt = "step";
-      endif
-      ncols = floor(sqrt(NOUT));
-      nrows = ceil(NOUT / ncols);
-      for i = 1:NOUT
-        subplot(nrows, ncols, i);
-        title(sprintf("%s: | %s -> %s", tt,sysgetsignals(sys,"in",inp,1), ...
-          sysgetsignals(sys,"out",i,1)));
-        if (DIGITAL)
-          [ts, ys] = stairs(t, y(i,:));
-          ts = ts(1:2*n-2)';  ys = ys(1:2*n-2)';
-          if (length(gm) > 0)
-            yy = [ys; gm(i)*ones(size(ts))];
-          else
-            yy = ys;
-          endif
+	## plot everything in one diagram
+	title([tt, " response | ", sysgetsignals(sys,"in",inp,1), ...
+               " -> all outputs"]);
+	if (DIGITAL)
+          stairs(t, y(i,:));
+	else
           grid("on");
           xlabel("time [s]");
           ylabel("y(t)");
-          plot(ts, yy);
-        else
-          if (length(gm) > 0)
-            yy = [y(i,:); gm(i)*ones(size(t))];
-          else
-            yy = y(i,:);
-          endif
-          grid("on");
-          xlabel("time [s]");
-          ylabel("y(t)");
-          plot(t, yy);
-        endif
-      endfor
-      ## leave gnuplot in multiplot mode is bad style
-      oneplot();
-    else
-      ## plot everything in one diagram
-      title([tt, " response | ", sysgetsignals(sys,"in",inp,1), ...
-        " -> all outputs"]);
-      if (DIGITAL)
-        stairs(t, y(i,:));
-      else
-        grid("on");
-        xlabel("time [s]");
-        ylabel("y(t)");
-        plot(t, y(i,:));
+          plot(t, y(i,:));
+	endif
       endif
+      y=[];
+      t=[];
     endif
-    y=[];
-    t=[];
-  endif
-  ## printf("##STEPIMP-DEBUG: gratulations, successfull completion.\n");
-endfunction
+    ## printf("##STEPIMP-DEBUG: gratulations, successfull completion.\n");
+  unwind_protect_cleanup
+    automatic_replot = save_automatic_replot;
+  end_unwind_protect
+endfunction