Mercurial > hg > octave-nkf
diff scripts/plot/private/__line__.m @ 14535:8150ccfffa22
Apply broadcasting to inputs of line().
* __line__.m: Use broadcasting the match the sizes of inputs.
* line.m: Add demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 06 Apr 2012 19:21:16 -0400 |
parents | 3d4f7631baff |
children | abf384f5d243 |
line wrap: on
line diff
--- a/scripts/plot/private/__line__.m +++ b/scripts/plot/private/__line__.m @@ -46,7 +46,15 @@ endif if (num_data_args > 0 && ! size_equal (varargin{1:num_data_args})) - error ("line: number of X, Y, and Z points must be equal"); + n = 1:num_data_args; + m = cellfun (@numel, varargin(1:num_data_args)); + [~, m] = max (m); + b = ones (size (varargin{m(1)})); + try + varargin(n) = cellfun (@(x) bsxfun (@times, b, x), varargin(n), "uniformoutput", false); + catch + error ("line: number of X, Y, and Z points must be equal"); + end_try_catch endif if (rem (nvargs - num_data_args, 2) != 0)