changeset 18165:d6aaf821cf8f

Add input validation for scatter(3) functions (bug #40898) * __scatter__.m: Add input validation to scatter family of functions.
author Rik <rik@octave.org>
date Mon, 23 Dec 2013 21:42:33 -0800
parents c56ce7c65019
children c9b4d3177de3
files scripts/plot/draw/private/__scatter__.m
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/private/__scatter__.m	Mon Dec 23 20:17:51 2013 -0500
+++ b/scripts/plot/draw/private/__scatter__.m	Mon Dec 23 21:42:33 2013 -0800
@@ -84,6 +84,21 @@
     c = [];
   endif
 
+  ## Validate inputs
+  if (nd == 2 && ! size_equal (x, y)) 
+    error ([fcn ": X and Y must have the same size"]);
+  elseif (nd == 3 && ! size_equal (x, y, z)) 
+    error ([fcn ": X, Y, and Z must have the same size"]);
+  endif
+
+  if (! isscalar (s) && ! size_equal (x, s))
+    error ([fcn ": size of S must match X, Y, and Z"]);
+  endif
+
+  if (rows (c) > 1 && rows (c) != rows (x))
+    error ([fcn ": number of colors in C must match number of points in X"]);
+  endif
+
   newargs = {};
   filled = false;
   have_marker = false;