changeset 6448:2110cc251779

[project @ 2007-03-24 02:47:36 by jwe]
author jwe
date Sat, 24 Mar 2007 02:47:36 +0000
parents 3f79532415b5
children a5de12c0f968
files scripts/ChangeLog scripts/control/base/__stepimp__.m scripts/control/base/frdemo.m scripts/control/base/nichols.m scripts/control/base/nyquist.m scripts/control/base/pzmap.m scripts/control/base/rldemo.m scripts/control/hinf/dhinfdemo.m scripts/control/hinf/hinfdemo.m scripts/general/bicubic.m scripts/general/interp2.m scripts/plot/__errplot__.m scripts/plot/bar.m scripts/plot/errorbar.m scripts/plot/grid.m scripts/plot/loglog.m scripts/plot/loglogerr.m scripts/plot/plot.m scripts/plot/plot3.m scripts/plot/polar.m scripts/plot/semilogx.m scripts/plot/semilogxerr.m scripts/plot/semilogy.m scripts/plot/semilogyerr.m scripts/plot/shg.m scripts/plot/stairs.m scripts/plot/subplot.m scripts/plot/xlabel.m scripts/signal/freqz_plot.m
diffstat 29 files changed, 248 insertions(+), 306 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/ChangeLog	Sat Mar 24 02:47:36 2007 +0000
@@ -1,8 +1,12 @@
 2007-03-23  John W. Eaton  <jwe@octave.org>
 
-	* control/base/bode.m, quaternion/demoquat.m,
-	quaternion/qcoordinate_plot.m, statistics/base/qqplot.m,
-	statistics/base/ppplot.m, sparse/spy.m:
+	* general/interp2.m, general/bicubic.m, control/base/rldemo.m,
+	control/hinf/hinfdemo.m, control/hinf/dhinfdemo.m,
+	control/base/nyquist.m, control/base/nichols.m,
+	control/base/frdemo.m, signal/freqz_plot.m,
+	control/base/__stepimp__.m, control/base/bode.m,
+	quaternion/demoquat.m, quaternion/qcoordinate_plot.m,
+	statistics/base/qqplot.m, statistics/base/ppplot.m, sparse/spy.m:
 	Update plotting code.
 
 	* control/base/bode.m: Unwrap phase angle.
--- a/scripts/control/base/__stepimp__.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/base/__stepimp__.m	Sat Mar 24 02:47:36 2007 +0000
@@ -37,11 +37,14 @@
 
 function [y, t] = __stepimp__ (sitype, sys, inp, tstop, n)
 
-  if (sitype == 1)         IMPULSE = 0;
-  elseif (sitype == 2)     IMPULSE = 1;
-  else                     error("__stepimp__: invalid sitype argument.")
+  if (sitype == 1)
+    IMPULSE = 0;
+  elseif (sitype == 2)
+    IMPULSE = 1;
+  else
+    error ("__stepimp__: invalid sitype argument");
   endif
-  sys = sysupdate(sys,"ss");
+  sys = sysupdate (sys, "ss");
 
   USE_DEF = 0;   # default tstop and n if we have to give up
   N_MIN = 50;    # minimum number of points
@@ -49,27 +52,31 @@
   T_DEF = 10.0;  # default simulation time
 
   ## collect useful information about the system
-  [ncstates,ndstates,NIN,NOUT] = sysdimensions(sys);
-  TSAMPLE = sysgettsam(sys);
+  [ncstates, ndstates, NIN, NOUT] = sysdimensions (sys);
+  TSAMPLE = sysgettsam (sys);
 
-  if (nargin < 3)                      inp = 1;
-  elseif (inp < 1 | inp > NIN)         error("Argument inp out of range")
+  if (nargin < 3)
+    inp = 1;
+  elseif (inp < 1 || inp > NIN)
+    error ("__stepimp__: argument inp out of range");
   endif
 
-  DIGITAL = is_digital(sys);
+  DIGITAL = is_digital (sys);
   if (DIGITAL)
     NSTATES = ndstates;
     if (TSAMPLE < eps)
-      error("__stepimp__: sampling time of discrete system too small.")
+      error ("__stepimp__: sampling time of discrete system too small")
     endif
-  else        NSTATES = ncstates;       endif
+  else
+    NSTATES = ncstates;
+  endif
   if (NSTATES < 1)
-    error("step: pure gain block (n_states < 1), step response is trivial");
+    error ("__stepimp__: 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
-    ev = eig(sys2ss(sys));
+    ev = eig (sys2ss (sys));
     if (DIGITAL)
       ## perform bilinear transformation on poles in z
       for i = 1:NSTATES
@@ -84,7 +91,7 @@
     ## remove poles near zero from eigenvalue array ev
     nk = NSTATES;
     for i = 1:NSTATES
-      if (abs(real(ev(i))) < 1.0e-10)
+      if (abs (real (ev(i))) < 1.0e-10)
         ev(i) = 0;
         nk = nk - 1;
       endif
@@ -93,14 +100,14 @@
       USE_DEF = 1;
       ## printf("##STEPIMP-DEBUG: using defaults.\n");
     else
-      ev = ev(find(ev));
-      x = max(abs(ev));
+      ev = ev(find (ev));
+      x = max (abs (ev));
       t_step = 0.2 * pi / x;
-      x = min(abs(real(ev)));
+      x = min (abs (real (ev)));
       t_sim = 5.0 / x;
       ## round up
-      yy = 10^(ceil(log10(t_sim)) - 1);
-      t_sim = yy * ceil(t_sim / yy);
+      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);
     endif
@@ -109,9 +116,9 @@
   if (DIGITAL)
     ## ---- sampled system
     if (nargin == 5)
-      n = round(n);
+      n = round (n);
       if (n < 2)
-        error("__stepimp__: n must not be less than 2.")
+        error ("__stepimp__: n must not be less than 2.")
       endif
     else
       if (nargin == 4)
@@ -124,13 +131,15 @@
           tstop = t_sim;
         endif
       endif
-      n = floor(tstop / TSAMPLE) + 1;
-      if (n < 2)  n = 2;  endif
+      n = floor (tstop / TSAMPLE) + 1;
+      if (n < 2)
+	n = 2;
+      endif
       if (n > N_MAX)
         n = N_MAX;
-        printf("Hint: number of samples limited to %d by default.\n", \
-               N_MAX);
-        printf("  ==> increase \"n\" parameter for longer simulations.\n");
+        printf ("Hint: number of samples limited to %d by default.\n", \
+		N_MAX);
+        printf ("  ==> increase \"n\" parameter for longer simulations.\n");
       endif
     endif
     tstop = (n - 1) * TSAMPLE;
@@ -138,7 +147,7 @@
   else
     ## ---- continuous system
     if (nargin == 5)
-      n = round(n);
+      n = round (n);
       if (n < 2)
         error("step: n must not be less than 2.")
       endif
@@ -150,7 +159,7 @@
           n = N_MIN;
           t_step = tstop / (n - 1);
         else
-          n = floor(tstop / t_step) + 1;
+          n = floor (tstop / t_step) + 1;
         endif
       else
         ## tstop and n are unknown
@@ -160,7 +169,7 @@
           t_step = tstop / (n - 1);
         else
           tstop = t_sim;
-          n = floor(tstop / t_step) + 1;
+          n = floor (tstop / t_step) + 1;
         endif
       endif
       if (n < N_MIN)
@@ -174,9 +183,9 @@
       endif
     endif
     tstop = (n - 1) * t_step;
-    [jnk,B] = sys2ss(sys);
+    [jnk,B] = sys2ss (sys);
     B = B(:,inp);
-    sys = c2d(sys, t_step);
+    sys = c2d (sys, t_step);
   endif
   ## printf("##STEPIMP-DEBUG: t_step=%f n=%d  tstop=%f\n", t_step, n, tstop);
 
@@ -184,12 +193,12 @@
   G = sys.b(:,inp);
   C = sys.c;
   D = sys.d(:,inp);
-  y = zeros(NOUT, n);
-  t = linspace(0, tstop, n);
+  y = zeros (NOUT, n);
+  t = linspace (0, tstop, n);
 
   if (IMPULSE)
-    if (!DIGITAL && (D'*D > 0))
-      error("impulse: D matrix is nonzero, impulse response infinite.")
+    if (! DIGITAL && D'*D > 0)
+      error ("impulse: D matrix is nonzero, impulse response infinite.")
     endif
     if (DIGITAL)
       y(:,1) = D / t_step;
@@ -207,71 +216,56 @@
       y *= t_step; 
     endif 
   else
-    x = zeros(NSTATES, 1);
+    x = zeros (NSTATES, 1);
     for i = 1:n
       y(:,i) = C * x + D;
       x = F * x + G;
     endfor
   endif
   
-  save_automatic_replot = automatic_replot;
-  unwind_protect
-    automatic_replot(0);
-    if(nargout == 0)
-      ## Plot the information
-      oneplot();
-      __gnuplot_set__ nogrid
-      __gnuplot_set__ nologscale
-      __gnuplot_set__ autoscale
-      __gnuplot_set__ nokey
-      if (IMPULSE)
-	gm = zeros(NOUT, 1);
-	tt = "impulse";
+  if (nargout == 0)
+    if (IMPULSE)
+      gm = zeros (NOUT, 1);
+      tt = "impulse";
+    else
+      ssys = ss (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);
+      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 (ts, yy);
+	grid ("on");
+	xlabel ("time [s]");
+	ylabel ("y(t)");
       else
-	ssys = ss(F, G, C, D, t_step);
-	gm = dcgain(ssys);
-	tt = "step";
-      endif
-      ncols = floor(sqrt(NOUT));
-      nrows = ceil(NOUT / ncols);
-      if (ncols > 1 || nrows > 1)
-	clearplot();
+	if (length (gm) > 0)
+	  yy = [y(i,:); gm(i)*ones(size(t))];
+	else
+	  yy = y(i,:);
+	endif
+	plot (t, yy);
+	grid ("on");
+	xlabel ("time [s]");
+	ylabel ("y(t)");
       endif
-      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();
-      y=[];
-      t=[];
-    endif
-    ## printf("##STEPIMP-DEBUG: gratulations, successfull completion.\n");
-  unwind_protect_cleanup
-    automatic_replot(save_automatic_replot);
-  end_unwind_protect
+      title (sprintf ("%s: | %s -> %s", tt,
+		      sysgetsignals (sys, "in", inp, 1),
+		      sysgetsignals (sys, "out", i, 1)));
+    endfor
+    y = [];
+    t = [];
+  endif
+  ## printf("##STEPIMP-DEBUG: gratulations, successfull completion.\n");
 endfunction  
--- a/scripts/control/base/frdemo.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/base/frdemo.m	Sat Mar 24 02:47:36 2007 +0000
@@ -546,9 +546,7 @@
           eval(cmd);
           disp("\nTo view the system's nyquist plot, execute the following");
           disp("commands:\n");
-          cmd = "__gnuplot_set__ xrange [-4:2];";
-          disp(cmd); eval(cmd);
-          cmd = "__gnuplot_set__ yrange [-2.5:2.5];";
+          cmd = "axis ([-4, 2, -2.5, 2.5]);";
           disp(cmd); eval(cmd);
           cmd = "nyquist(dsys3);";
           run_cmd;
--- a/scripts/control/base/nichols.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/base/nichols.m	Sat Mar 24 02:47:36 2007 +0000
@@ -68,7 +68,7 @@
 ## @end table
 ## If no output arguments are given, @command{nichols} plots the results to the screen.
 ## Descriptive labels are automatically placed. See @command{xlabel}, 
-## @command{ylabel}, @command{title}, and @command{replot}.
+## @command{ylabel}, and @command{title}.
 ##
 ## Note: if the requested plot is for an @acronym{MIMO} system, @var{mag} is set to
 ## @iftex
@@ -85,61 +85,62 @@
 function [mag, phase, w] = nichols (sys, w, outputs, inputs)
 
   ## check number of input arguments given
-  if (nargin < 1 | nargin > 4)
+  if (nargin < 1 || nargin > 4)
     print_usage ();
   endif
-  if(nargin < 2)
+  if (nargin < 2)
     w = [];
   endif
-  if(nargin < 3)
+  if (nargin < 3)
     outputs = [];
   endif
-  if(nargin < 4)
+  if (nargin < 4)
     inputs = [];
   endif
 
   [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nichols");
 
-  [stname,inname,outname] = sysgetsignals(sys);
-  systsam = sysgettsam(sys);
+  [stname,inname,outname] = sysgetsignals (sys);
+  systsam = sysgettsam (sys);
 
   ## Get the magnitude and phase of f.
-  mag = abs(f);
-  phase = arg(f)*180.0/pi;
+  mag = abs (f);
+  phase = arg (f)*180.0/pi;
 
   if (nargout < 1),
     ## Plot the information
-    oneplot();
-    __gnuplot_set__ autoscale;
-    __gnuplot_set__ nokey;
-    clearplot();
-    grid("on");
-    __gnuplot_set__ data style lines;
-    if(is_digital(sys))
+
+    if (max (mag) > 0)
+      plot (phase, 20 * log10 (mag));
+      ylabel ("Gain in dB");
+    else
+      plot (phase, mag);
+      ylabel ("Gain |Y/U|")
+    endif
+
+    grid ("on");
+
+    if (is_digital (sys))
       tistr = "(exp(jwT)) ";
     else
       tistr = "(jw)";
     endif
-    xlabel("Phase (deg)");
-    if(is_siso(sys))
-      title(["Nichols plot of |[Y/U]",tistr,"|, u=", ...
-        sysgetsignals(sys,"in",1,1), ", y=",sysgetsignals(sys,"out",1,1)]);
+
+    xlabel ("Phase (deg)");
+
+    if (is_siso (sys))
+      title (sprintf ("Nichols plot of |[Y/U]%s|, u=%s, y=%s", tistr,
+		      sysgetsignals (sys, "in", 1, 1),
+		      sysgetsignals (sys, "out", 1, 1));
     else
-      title([ "||Y(", tistr, ")/U(", tistr, ")||"]);
-      printf("MIMO plot from\n%s\nto\n%s\n",__outlist__(inname,"    "), ...
-        __outlist__(outname,"       "));
-    endif
-    if(max(mag) > 0)
-      ylabel("Gain in dB");
-      md = 20*log10(mag);
-    else
-      ylabel("Gain |Y/U|")
-      md = mag;
+      title ([ "||Y(", tistr, ")/U(", tistr, ")||"]);
+      printf ("MIMO plot from\n%s\nto\n%s\n", __outlist__ (inname, "    "),
+              __outlist__ (outname, "       "));
     endif
 
-    axvec = axis2dlim([vec(phase),vec(md)]);
-    axis(axvec);
-    plot(phase,md);
+    axis (axis2dlim ([phase(:), md(:)]));
+
     mag = phase = w = [];
   endif
+
 endfunction
--- a/scripts/control/base/nyquist.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/base/nyquist.m	Sat Mar 24 02:47:36 2007 +0000
@@ -105,22 +105,22 @@
   ## response is plotted is different between the two functions.
 
   ## check number of input arguments given
-  if (nargin < 1 | nargin > 5)
+  if (nargin < 1 || nargin > 5)
     print_usage ();
   endif
-  if(nargin < 2)
+  if (nargin < 2)
     w = [];
   endif
-  if(nargin < 3)
+  if (nargin < 3)
     outputs = [];
   endif
-  if(nargin < 4)
+  if (nargin < 4)
     inputs = [];
   endif
-  if(nargin < 5)
+  if (nargin < 5)
     atol = 0;
-  elseif(!(is_sample(atol) | atol == 0))
-    error("atol must be a nonnegative scalar.")
+  elseif (! (is_sample (atol) || atol == 0))
+    error ("nyquist: atol must be a nonnegative scalar")
   endif
 
   ## signal to __bodquist__ who's calling
@@ -128,84 +128,84 @@
   [f, w, sys] = __bodquist__ (sys, w, outputs, inputs, "nyquist");
 
   ## Get the real and imaginary part of f.
-  realp = real(f);
-  imagp = imag(f);
+  realp = real (f);
+  imagp = imag (f);
 
   ## No output arguments, then display plot, otherwise return data.
   if (nargout == 0)
     dnplot = 0;
-    while(!dnplot)
-      oneplot();
-      __gnuplot_set__ key;
-      clearplot();
+    while (! dnplot)
+      plot (realp, imagp, "- ;+w;", realp, -imagp, "-@ ;-w;");
+
       grid ("on");
-      __gnuplot_set__ data style lines;
 
-      if(is_digital(sys))
+      if (is_digital (sys))
         tstr = " G(e^{jw}) ";
       else
         tstr = " G(jw) ";
       endif
-      xlabel(["Re(",tstr,")"]);
-      ylabel(["Im(",tstr,")"]);
+      xlabel (sprintf ("Re(%s)", tstr));
+      ylabel (sprintf ("Im(%s)", tstr));
 
-      [stn, inn, outn] = sysgetsignals(sys);
-      if(is_siso(sys))
-        title(sprintf("Nyquist plot from %s to %s, w (rad/s) in [%e, %e]", ...
-          inn{1}, outn{1}, w(1), w(length(w))) )
+      [stn, inn, outn] = sysgetsignals (sys);
+      if (is_siso (sys))
+        title (sprintf ("Nyquist plot from %s to %s, w (rad/s) in [%e, %e]",
+			inn{1}, outn{1}, w(1), w(end)));
       endif
 
-      __gnuplot_set__ nologscale xy;
-
-      axis(axis2dlim([[vec(realp),vec(imagp)];[vec(realp),-vec(imagp)]]));
-      plot(realp,imagp,"- ;+w;",realp,-imagp,"-@ ;-w;");
+      axis (axis2dlim ([[realp(:), imagp(:)]; [realp(:), -imagp(:)]]));
 
       ## check for interactive plots
       dnplot = 1; # assume done; will change later if atol is satisfied
-      if(atol > 0 & length(f) > 2)
+      if (atol > 0 && length (f) > 2)
 
         ## check for asymptotes
-        fmax = max(abs(f));
-        fi = find(abs(f) == fmax, 1, "last");
+        fmax = max (abs (f));
+        fi = find (abs (f) == fmax, 1, "last");
 
         ## compute angles from point to point
-        df = diff(f);
-        th = atan2(real(df),imag(df))*180/pi;
+        df = diff (f);
+        th = atan2 (real (df), imag (df)) * 180 / pi;
 
         ## get angle at fmax
-        if(fi == length(f)) fi = fi-1; endif
+        if (fi == length(f))
+	  fi = fi-1;
+	endif
         thm = th(fi);
 
         ## now locate consecutive angles within atol of thm
-        ith_same = find(abs(th - thm) < atol);
-        ichk = union(fi,find(diff(ith_same) == 1));
+        ith_same = find (abs (th - thm) < atol);
+        ichk = union (fi, find (diff (ith_same) == 1));
 
         ## locate max, min consecutive indices in ichk
-        loval = max(complement(ichk,1:fi));
-        if(isempty(loval)) loval = fi;
-        else               loval = loval + 1;   endif
+        loval = max (complement (ichk, 1:fi));
+        if (isempty (loval))
+	  loval = fi;
+        else
+          loval = loval + 1;
+	endif
 
-        hival = min(complement(ichk,fi:length(th)));
-        if(isempty(hival))  hival = fi+1;      endif
+        hival = min (complement (ichk, fi:length(th)));
+        if (isempty (hival))
+	  hival = fi+1;
+	endif
 
-        keep_idx = complement(loval:hival,1:length(w));
+        keep_idx = complement (loval:hival, 1:length(w));
 
-        if(length(keep_idx))
-          resp = input("Remove asymptotes and zoom in (y or n): ",1);
-          if(resp(1) == "y")
+        if (length (keep_idx))
+          resp = input ("Remove asymptotes and zoom in (y or n): ", 1);
+          if (resp(1) == "y")
             dnplot = 0;                 # plot again
             w = w(keep_idx);
             f = f(keep_idx);
-            realp = real(f);
-            imagp = imag(f);
+            realp = real (f);
+            imagp = imag (f);
           endif
         endif
 
      endif
-    endwhile
-    w = [];
-    realp=[];
-    imagp=[];
-  endif
+   endwhile
+   w = realp = imagp = [];
+ endif
 
 endfunction
--- a/scripts/control/base/pzmap.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/base/pzmap.m	Sat Mar 24 02:47:36 2007 +0000
@@ -37,53 +37,53 @@
 ## @end table
 ## @end deftypefn
 
-function [zer, pol]=pzmap (sys)
+function [zer, pol] = pzmap (sys)
 
-  if(nargin != 1)
+  if (nargin != 1)
     print_usage ();
-  elseif (!isstruct(sys));
-    error("sys must be in system format");
+  elseif (! isstruct (sys));
+    error ("pzmap: sys must be in system format");
   endif
 
-  [zer,pol] = sys2zp(sys);
+  [zer, pol] = sys2zp (sys);
 
   ## force to column vectors, split into real, imaginary parts
   zerdata = poldata = [];
-  if(length(zer))
-    zer = reshape(zer,length(zer),1);
+  if (length (zer))
+    zer = reshape (zer, length (zer), 1);
     zerdata = [real(zer(:,1)), imag(zer(:,1))];
   endif
-  if(length(pol))
-    pol = reshape(pol,length(pol),1);
+  if (length (pol))
+    pol = reshape (pol, length (pol), 1);
     poldata = [real(pol(:,1)), imag(pol(:,1))];
   endif
 
   ## determine continuous or discrete plane
   vars = "sz";
-  varstr = vars(is_digital(sys) + 1);
+  varstr = vars(is_digital (sys) + 1);
 
   ## Plot the data
-  __gnuplot_set__ nologscale xy;
-  if(is_siso(sys))
-    title(sprintf("Pole-zero map from %s to %s", ...
-	 sysgetsignals(sys,"in",1,1), sysgetsignals(sys,"out",1,1) ));
+
+  if (length (zer) == 0)
+    plot (poldata(:,1), poldata(:,2), "@12 ;poles (no zeros);");
+  elseif (length (pol) == 0)
+    plot (zerdata(:,1), zerdata(:,2), "@31 ;zeros (no poles);");
+  else
+    plot (zerdata(:,1), zerdata(:,2), "@31 ;zeros;",
+	  poldata(:,1), poldata(:,2), "@12 ;poles;");
   endif
-  xlabel(["Re(",varstr,")"]);
-  ylabel(["Im(",varstr,")"]);
-  grid;
+
+  if (is_siso (sys))
+    title (sprintf ("Pole-zero map from %s to %s",
+		    sysgetsignals (sys, "in", 1, 1),
+		    sysgetsignals (sys, "out", 1, 1)));
+  endif
+
+  xlabel (sprintf ("Re(%s)", varstr));
+  ylabel (sprintf ("Im(%s)", varstr));
+  grid ("on");
 
   ## compute axis limits
-  axis(axis2dlim([zerdata;poldata]));
-  grid
-  ## finally, plot the data
-  if(length(zer) == 0)
-    plot(poldata(:,1), poldata(:,2),"@12 ;poles (no zeros);");
-  elseif(length(pol) == 0)
-    plot(zerdata(:,1), zerdata(:,2),"@31 ;zeros (no poles);");
-  else
-    plot(zerdata(:,1), zerdata(:,2),"@31 ;zeros;", ...
-	poldata(:,1), poldata(:,2),"@12 ;poles;");
-  endif
-  replot
+  axis (axis2dlim ([zerdata; poldata]));
 
 endfunction
--- a/scripts/control/base/rldemo.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/base/rldemo.m	Sat Mar 24 02:47:36 2007 +0000
@@ -36,7 +36,6 @@
         "Display root locus diagram of SISO continuous system (rlocus)", ...
         "Display root locus diagram of SISO discrete system (rlocus)", ...
         "Return to main demo menu");
-    __gnuplot_set__ autoscale
     if (k == 1)
       clc
       help pzmap
--- a/scripts/control/hinf/dhinfdemo.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/hinf/dhinfdemo.m	Sat Mar 24 02:47:36 2007 +0000
@@ -151,8 +151,8 @@
     if (columns(mag2) > 1);  mag2 = mag2';  endif
     figure(fig_n)
     fig_n = fig_n + 1;
-    __gnuplot_set__ grid
     loglog(ww, [mag1 mag2]);
+    grid ("on");
   endif
 endif
 
--- a/scripts/control/hinf/hinfdemo.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/control/hinf/hinfdemo.m	Sat Mar 24 02:47:36 2007 +0000
@@ -401,8 +401,8 @@
         if (columns(mag2) > 1);  mag2 = mag2';  endif
         figure(fig_n)
         fig_n = fig_n + 1;
-        __gnuplot_set__ grid
         loglog(ww, [mag1 mag2]);
+        grid ("on");
       endif
     endif
 
--- a/scripts/general/bicubic.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/general/bicubic.m	Sat Mar 24 02:47:36 2007 +0000
@@ -194,5 +194,4 @@
 %! yi=linspace(min(y),max(y),26);
 %! mesh(xi,yi,bicubic(x,y,A,xi,yi));
 %! [x,y] = meshgrid(x,y);
-%! __gnuplot_raw__ ("set nohidden3d;\n")
 %! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
--- a/scripts/general/interp2.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/general/interp2.m	Sat Mar 24 02:47:36 2007 +0000
@@ -239,7 +239,6 @@
 %! yi=linspace(min(y),max(y),26)';
 %! mesh(xi,yi,interp2(x,y,A,xi,yi,'linear'));
 %! [x,y] = meshgrid(x,y); 
-%! __gnuplot_raw__ ("set nohidden3d;\n")
 %! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
 
 %!demo
@@ -249,7 +248,6 @@
 %! yi=linspace(min(y),max(y),26)';
 %! mesh(xi,yi,interp2(x,y,A,xi,yi,'nearest'));
 %! [x,y] = meshgrid(x,y); 
-%! __gnuplot_raw__ ("set nohidden3d;\n")
 %! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
 
 %!#demo
@@ -259,7 +257,6 @@
 %! yi=linspace(min(y),max(y),26);
 %! mesh(xi,yi,interp2(x,y,A,xi,yi,'cubic'));
 %! [x,y] = meshgrid(x,y); 
-%! __gnuplot_raw__ ("set nohidden3d;\n")
 %! hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
 
 %!test % simple test
--- a/scripts/plot/__errplot__.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/__errplot__.m	Sat Mar 24 02:47:36 2007 +0000
@@ -26,7 +26,7 @@
 ## @end example
 ##
 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__,
-## bar, stairs, errorbar, replot, xlabel, ylabel, title}
+## bar, stairs, errorbar, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Created: 18.7.2000
--- a/scripts/plot/bar.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/bar.m	Sat Mar 24 02:47:36 2007 +0000
@@ -42,7 +42,7 @@
 ## @noindent
 ## are equivalent.
 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
-## stairs, replot, xlabel, ylabel, title}
+## stairs, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/errorbar.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/errorbar.m	Sat Mar 24 02:47:36 2007 +0000
@@ -102,7 +102,7 @@
 ## are drawn from @var{x}-@var{lx} to @var{x}+@var{ux} and @var{y} errorbars
 ## from @var{y}-@var{ly} to @var{y}+@var{uy}.
 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__,
-## bar, stairs, replot, xlabel, ylabel, title}
+## bar, stairs, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Created: 18.7.2000
--- a/scripts/plot/grid.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/grid.m	Sat Mar 24 02:47:36 2007 +0000
@@ -29,7 +29,7 @@
 ## be either @code{"on"} or @code{"off"} to explicitly set the state of
 ## the minor grid.
 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
-## bar, stairs, replot, xlabel, ylabel, title}
+## bar, stairs, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/loglog.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/loglog.m	Sat Mar 24 02:47:36 2007 +0000
@@ -23,7 +23,7 @@
 ## description of @code{plot} for a description of the arguments that
 ## @code{loglog} will accept.
 ## @seealso{plot, semilogy, loglog, polar, mesh, contour, bar, stairs,
-## replot, xlabel, ylabel, title}
+## xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/loglogerr.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/loglogerr.m	Sat Mar 24 02:47:36 2007 +0000
@@ -33,7 +33,7 @@
 ## format defined by @var{fmt}. See errorbar for available formats and 
 ## additional information.
 ## @seealso{errorbar, semilogxerr, semilogyerr, polar, mesh, contour, 
-## __pltopt__, bar, stairs, replot, xlabel, ylabel, title}
+## __pltopt__, bar, stairs, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Created: 20.2.2001
--- a/scripts/plot/plot.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/plot.m	Sat Mar 24 02:47:36 2007 +0000
@@ -160,7 +160,7 @@
 ## This will plot the cosine and sine functions and label them accordingly
 ## in the key.
 ## @seealso{semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__
-## bar, stairs, errorbar, replot, xlabel, ylabel, title, print}
+## bar, stairs, errorbar, xlabel, ylabel, title, print}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/plot3.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/plot3.m	Sat Mar 24 02:47:36 2007 +0000
@@ -87,7 +87,7 @@
 ## @end example
 ##
 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__
-## bar, stairs, errorbar, replot, xlabel, ylabel, title, print}
+## bar, stairs, errorbar, xlabel, ylabel, title, print}
 ## @end deftypefn
 
 ## Author: Paul Kienzle
--- a/scripts/plot/polar.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/polar.m	Sat Mar 24 02:47:36 2007 +0000
@@ -24,7 +24,7 @@
 ##
 ## The optional third argument specifies the line type.
 ## @seealso{plot, semilogx, semilogy, loglog, mesh, contour, bar,
-## stairs, replot, xlabel, ylabel, title}
+## stairs, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/semilogx.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/semilogx.m	Sat Mar 24 02:47:36 2007 +0000
@@ -23,7 +23,7 @@
 ## the description of @code{plot} for a description of the arguments
 ## that @code{semilogx} will accept.
 ## @seealso{plot, semilogy, loglog, polar, mesh, contour, bar, stairs,
-## replot, xlabel, ylabel, title}
+## xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/semilogxerr.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/semilogxerr.m	Sat Mar 24 02:47:36 2007 +0000
@@ -33,7 +33,7 @@
 ## format defined by @var{fmt}. See errorbar for available formats and 
 ## additional information.
 ## @seealso{errorbar, loglogerr semilogyerr, polar, mesh, contour, __pltopt__, 
-## bar, stairs, replot, xlabel, ylabel, title}
+## bar, stairs, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Created: 20.2.2001
--- a/scripts/plot/semilogy.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/semilogy.m	Sat Mar 24 02:47:36 2007 +0000
@@ -23,7 +23,7 @@
 ## the description of @code{plot} for a description of the arguments
 ## that @code{semilogy} will accept.
 ## @seealso{plot, semilogx, loglog, polar, mesh, contour, bar, stairs,
-## replot, xlabel, ylabel, title}
+## xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/semilogyerr.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/semilogyerr.m	Sat Mar 24 02:47:36 2007 +0000
@@ -33,7 +33,7 @@
 ## format defined by @var{fmt}. See errorbar for available formats and 
 ## additional information.
 ## @seealso{errorbar, loglogerr semilogxerr, polar, mesh, contour, __pltopt__, 
-## bar, stairs, replot, xlabel, ylabel, title}
+## bar, stairs,  xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Created: 20.2.2001
--- a/scripts/plot/shg.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/shg.m	Sat Mar 24 02:47:36 2007 +0000
@@ -21,9 +21,9 @@
 ## @deftypefn {Function File} {} shg
 ##
 ## Show the graph window.  Currently, this is the same as executing
-## replot.
+## @code{drawnow}.
 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
-## bar, stairs, replot, xlabel, ylabel}
+## bar, stairs, xlabel, ylabel}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/stairs.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/stairs.m	Sat Mar 24 02:47:36 2007 +0000
@@ -42,7 +42,7 @@
 ## @noindent
 ## are equivalent.
 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
-## bar, replot, xlabel, ylabel, title}
+## bar, xlabel, ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/plot/subplot.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/subplot.m	Sat Mar 24 02:47:36 2007 +0000
@@ -20,21 +20,8 @@
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} subplot (@var{rows}, @var{cols}, @var{index})
 ## @deftypefnx {Function File} {} subplot (@var{rcn})
-## Sets @code{gnuplot} in multiplot mode and plots in location
-## given by index (there are @var{cols} by @var{rows} subwindows).
-##
-## Input:
-##
-## @table @var
-## @item rows
-## Number of rows in subplot grid.
-##
-## @item columns
-## Number of columns in subplot grid.
-##
-## @item index
-## Index of subplot where to make the next plot.
-## @end table
+## Set up a plot grid with @var{cols} by @var{rows} subwindows and plot
+## in location given by @var{index}.
 ##
 ## If only one argument is supplied, then it must be a three digit value
 ## specifying the location in digits 1 (rows) and 2 (columns) and the plot
--- a/scripts/plot/xlabel.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/plot/xlabel.m	Sat Mar 24 02:47:36 2007 +0000
@@ -21,11 +21,9 @@
 ## @deftypefn {Function File} {} xlabel (@var{string})
 ## @deftypefnx {Function File} {} ylabel (@var{string})
 ## @deftypefnx {Function File} {} zlabel (@var{string})
-## Specify x, y, and z axis labels for the plot.  If you already have a plot
-## displayed, use the command @code{replot} to redisplay it with the new
-## labels.
+## Specify x, y, and z axis labels for the plot.
 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
-## bar, stairs, replot, ylabel, title}
+## bar, stairs,  ylabel, title}
 ## @end deftypefn
 
 ## Author: jwe
--- a/scripts/signal/freqz_plot.m	Sat Mar 24 00:00:31 2007 +0000
+++ b/scripts/signal/freqz_plot.m	Sat Mar 24 02:47:36 2007 +0000
@@ -24,7 +24,7 @@
 
 ## Author: Paul Kienzle <pkienzle@users.sf.net>
 
-function freqz_plot(w,h)
+function freqz_plot (w, h)
 
     n = length (w);
 
@@ -37,59 +37,24 @@
     phase = unwrap (arg (h));
     maxmag = max (mag);
 
-    unwind_protect
-
-      ## Protect graph state.
-
-      replot_state = automatic_replot;
-      automatic_replot(0);
-
-      subplot (311);
-      __gnuplot_set__ lmargin 10;
-      axis ("labely");
-      xlabel ("");
-      grid ("on");
-      axis ([ w(1), w(n), maxmag-3, maxmag ]);
-      plot (w, mag, ";Pass band (dB);");
+    subplot (3, 1, 1);
+    plot (w, mag, ";Pass band (dB);");
+    grid ("on");
+    axis ([w(1), w(n), maxmag-3, maxmag], "labely");
 
-      subplot (312);
-      axis ("labely");
-      title ("");
-      xlabel ("");
-      __gnuplot_set__ tmargin 0;
-      grid ("on");
-      if (maxmag - min (mag) > 100)
-      	axis ([ w(1), w(n), maxmag-100, maxmag ]);
-      else
-      	axis ("autoy");
-      endif
-      plot (w, mag, ";Stop band (dB);");
-      
-      subplot (313);
-      axis ("label");
-      title ("");
-      grid ("on");
-      axis ("autoy");
-      xlabel ("Frequency");
-      axis ([ w(1), w(n) ]);
-      plot (w, phase*360/(2*pi), ";Phase (degrees);");
-      
-    unwind_protect_cleanup
+    subplot (3, 1, 2);
+    plot (w, mag, ";Stop band (dB);");
+    grid ("on");
+    if (maxmag - min (mag) > 100)
+      axis ([w(1), w(n), maxmag-100, maxmag], "labely");
+    else
+      axis ("autoy", "labely");
+    endif
 
-      ## Restore graph state.
-
-      ## FIXME -- if automatic_replot is non-zero, this will
-      ## mess up the graph, however if we don't do it here then the user
-      ## will have to do it themselves.
-
-      grid ("off");
-      axis ("auto", "label");
-      __gnuplot_set__ lmargin;
-      __gnuplot_set__ tmargin;
-      oneplot ();
-
-      automatic_replot(replot_state);
-
-    end_unwind_protect
+    subplot (3, 1, 3);
+    plot (w, phase*360/(2*pi), ";Phase (degrees);");
+    grid ("on");
+    xlabel ("Frequency");
+    axis ([w(1), w(n)], "autoy", "label");
 
 endfunction