changeset 27046:7f605f88d1e3

Improve input validation for quiver, quiver3 (bug #56120). * __quiver__.m: Verify that sizes of position matrices (x,y,z) match those of the vector field (u,v,w).
author Rik <rik@octave.org>
date Thu, 11 Apr 2019 10:43:33 -0700
parents 2faa56886789
children 2e364bd8efb5
files scripts/plot/draw/private/__quiver__.m
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/private/__quiver__.m	Thu Apr 11 08:52:06 2019 -0700
+++ b/scripts/plot/draw/private/__quiver__.m	Thu Apr 11 10:43:33 2019 -0700
@@ -51,7 +51,17 @@
     if (is3d)
       w = varargin{ioff++};
     endif
+    if (is3d)
+      if (! size_equal (z, u, v, w))
+        error ("quiver3: Z, U, V, and W must be the same size");
+      endif
+    else
+      if (! size_equal (u, v))
+        error ("quiver: U and V must be the same size");
+      endif
+    endif
     [x, y] = meshgrid (1:columns (u), 1:rows (u));
+
     if (nargin >= ioff && isnumeric (varargin{ioff})
         && isscalar (varargin{ioff}))
       autoscale = varargin{ioff++};
@@ -75,6 +85,16 @@
         [x, y] = meshgrid (x, y);
       endif
     endif
+    if (is3d)
+      if (! size_equal (x, y, z, u, v, w))
+        error ("quiver3: X, Y, Z, U, V, and W must be the same size");
+      endif
+    else
+      if (! size_equal (x, y, u, v))
+        error ("quiver: X, Y, U, and V must be the same size");
+      endif
+    endif
+
     if (nargin >= ioff && isnumeric (varargin{ioff})
         && isscalar (varargin{ioff}))
       autoscale = varargin{ioff++};