changeset 736:c8f88bd3202b

[project @ 1994-09-24 03:28:05 by jwe]
author jwe
date Sat, 24 Sep 1994 03:29:38 +0000
parents 7455048010b9
children 5eb0d9359485
files scripts/plot/bar.m scripts/plot/hist.m scripts/plot/stairs.m
diffstat 3 files changed, 49 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/bar.m	Sat Sep 24 03:22:34 1994 +0000
+++ b/scripts/plot/bar.m	Sat Sep 24 03:29:38 1994 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 1993 John W. Eaton
+# Copyright (C) 1993, 1994 John W. Eaton
 # 
 # This file is part of Octave.
 # 
@@ -43,17 +43,17 @@
   if (nargin == 1)
     if (is_vector (x))
       len = 3 * length (x) + 1;
-      xb = yb = zeros (len, 1);
-      xb(1) = 0.5;
-      yb(1) = 0;
+      tmp_xb = tmp_yb = zeros (len, 1);
+      tmp_xb(1) = 0.5;
+      tmp_yb(1) = 0;
       k = 1;
       for i = 2:3:len
-        xb(i) = k-0.5;
-        xb(i+1) = k+0.5;
-        xb(i+2) = k+0.5;
-        yb(i) = x(k);
-        yb(i+1) = x(k);
-        yb(i+2) = 0.0;
+        tmp_xb(i) = k-0.5;
+        tmp_xb(i+1) = k+0.5;
+        tmp_xb(i+2) = k+0.5;
+        tmp_yb(i) = x(k);
+        tmp_yb(i+1) = x(k);
+        tmp_yb(i+2) = 0.0;
         k++;
       endfor
     else
@@ -65,18 +65,18 @@
       ylen = length (y);
       if (xlen == ylen)
         len = 3 * xlen + 1;
-        xb = yb = zeros (len, 1);
+        tmp_xb = tmp_yb = zeros (len, 1);
         delta = (x(2) - x(1)) / 2.0;
-        xb(1) = x(1) - delta;
-        yb(1) = 0.0;
+        tmp_xb(1) = x(1) - delta;
+        tmp_yb(1) = 0.0;
 	k = 1;
         for i = 2:3:len
-          xb(i) = xb(i-1);
-          xb(i+1) = xb(i) + 2.0 * delta;
-          xb(i+2) = xb(i+1);
-	  yb(i) = y(k);
-	  yb(i+1) = y(k);
-	  yb(i+2) = 0.0;
+          tmp_xb(i) = tmp_xb(i-1);
+          tmp_xb(i+1) = tmp_xb(i) + 2.0 * delta;
+          tmp_xb(i+2) = tmp_xb(i+1);
+	  tmp_yb(i) = y(k);
+	  tmp_yb(i+1) = y(k);
+	  tmp_yb(i+2) = 0.0;
           if (k < xlen)
             delta = (x(k+1) - x(k)) / 2.0;
             if (x(k+1) < x(k))
@@ -95,8 +95,11 @@
     error ("usage: [xb, yb] = bar (x, y)");
   endif
 
-  if (nargout == 1)
-    plot (xb, yb);
+  if (nargout == 0)
+    plot (tmp_xb, tmp_yb);
+  else
+    xb = tmp_xb;
+    yb = tmp_yb;
   endif
 
 endfunction
--- a/scripts/plot/hist.m	Sat Sep 24 03:22:34 1994 +0000
+++ b/scripts/plot/hist.m	Sat Sep 24 03:29:38 1994 +0000
@@ -87,21 +87,11 @@
   endfor
   freq (n) = sum (y >= cutoff (n-1));
 
-# With Octave 1.0, nargout is never zero, so we have to do this: 
-
-  nn = freq;
-  xx = x;
-  if (nargout != 2)
-    bar (xx, nn);
+  if (nargout == 2)
+    nn = freq;
+    xx = x;
+  else
+    bar (x, freq);
   endif
 
-# Once 1.1 is released, we can do this instead:
-#
-#  if (nargout == 2)
-#    nn = freq;
-#    xx = x;
-#  else
-#    bar (x, freq);
-#  endif
-
 endfunction
--- a/scripts/plot/stairs.m	Sat Sep 24 03:22:34 1994 +0000
+++ b/scripts/plot/stairs.m	Sat Sep 24 03:29:38 1994 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 1993 John W. Eaton
+# Copyright (C) 1993, 1994 John W. Eaton
 # 
 # This file is part of Octave.
 # 
@@ -44,13 +44,13 @@
   if (nargin == 1)
     if (is_vector (x))
       len = 2 * length (x);
-      xs = ys = zeros (len, 1);
+      tmp_xs = tmp_ys = zeros (len, 1);
       k = 0;
       for i = 1:2:len
-        xs(i) = k++;
-        ys(i) = x(k);
-        ys(i+1) = x(k);
-        xs(i+1) = k;
+        tmp_xs(i) = k++;
+        tmp_ys(i) = x(k);
+        tmp_ys(i+1) = x(k);
+        tmp_xs(i+1) = k;
       endfor
     else
       error ("stairs: argument must be a vector");
@@ -61,24 +61,24 @@
       ylen = length (y);
       if (xlen == ylen)
         len = 2 * xlen;
-        xs = ys = zeros (len, 1);
+        tmp_xs = tmp_ys = zeros (len, 1);
 	k = 1;
         len_m2 = len - 2;
 	for i = 1:2:len_m2
-	  xs(i) = x(k);
-	  ys(i) = y(k);
-	  ys(i+1) = y(k);
+	  tmp_xs(i) = x(k);
+	  tmp_ys(i) = y(k);
+	  tmp_ys(i+1) = y(k);
           k++;
-	  xs(i+1) = x(k);
+	  tmp_xs(i+1) = x(k);
           if (x(k) < x(k-1))
             error ("stairs: x vector values must be in ascending order");
           endif
 	endfor
-        xs(len-1) = x(xlen);
+        tmp_xs(len-1) = x(xlen);
         delta = x(xlen) - x(xlen-1);
-        xs(len) = x(xlen) + delta;
-        ys(len-1) = y(ylen);
-        ys(len) = y(ylen);
+        tmp_xs(len) = x(xlen) + delta;
+        tmp_ys(len-1) = y(ylen);
+        tmp_ys(len) = y(ylen);
       else
         error ("stairs: arguments must be the same length");
       endif
@@ -89,8 +89,11 @@
     error ("usage: [xs, ys] = stairs (x, y)");
   endif
 
-  if (nargout == 1)
-    plot (xs, ys);
+  if (nargout == 0)
+    plot (tmp_xs, tmp_ys);
+  else
+    xs = tmp_xs;
+    ys = tmp_ys;
   endif
 
 endfunction