Mercurial > hg > octave-lyh
diff scripts/plot/stairs.m @ 3426:f8dde1807dee
[project @ 2000-01-13 08:40:00 by jwe]
author | jwe |
---|---|
date | Thu, 13 Jan 2000 08:40:53 +0000 |
parents | ae7adbb591e8 |
children | 22bd65326ec1 |
line wrap: on
line diff
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -20,25 +20,25 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} stairs (@var{x}, @var{y}) ## Given two vectors of x-y data, bar produces a `stairstep' plot. -## +## ## If only one argument is given, it is taken as a vector of y-values ## and the x coordinates are taken to be the indices of the elements. -## +## ## If two output arguments are specified, the data are generated but ## not plotted. For example, -## +## ## @example ## stairs (x, y); ## @end example -## +## ## @noindent ## and -## +## ## @example ## [xs, ys] = stairs (x, y); ## plot (xs, ys); ## @end example -## +## ## @noindent ## are equivalent. ## @end deftypefn @@ -71,18 +71,18 @@ if (xlen == ylen) len = 2 * xlen; tmp_xs = tmp_ys = zeros (len, 1); - k = 1; + k = 1; len_m2 = len - 2; - for i = 1:2:len_m2 - tmp_xs(i) = x(k); - tmp_ys(i) = y(k); - tmp_ys(i+1) = y(k); + for i = 1:2:len_m2 + tmp_xs(i) = x(k); + tmp_ys(i) = y(k); + tmp_ys(i+1) = y(k); k++; - tmp_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 + endfor tmp_xs(len-1) = x(xlen); delta = x(xlen) - x(xlen-1); tmp_xs(len) = x(xlen) + delta;