comparison scripts/plot/draw/private/__quiver__.m @ 32062:ada96a467a28

quiver: Improve plotting with non-float numeric inputs (bug #59695) * scripts/plot/draw/private/__quiver__.m: Change firstnonnumeric check to look for char instead of numeric to allow for logical inputs. Recast all inputs up to firstnonnumeric as doubles. Check if firstnonnumeric element is 'off' and if so set scale factor to 0 and increment firstnonnumeric. * scripts/plot/draw/quiver.m: Update docstring to include scaling factor option 'off'. Add BIST for int and logical input types. * scripts/plot/draw/quiver3.m: Update docstring to include scaling factor option 'off'. Add BISTs for too-few inputs. * etc/NEWS.9.md: Appended details of changes to quiver note under General Improvements and noted it also applies to quiver3.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Wed, 26 Apr 2023 17:18:50 -0400
parents 29671873411a
children 03fe0b635d2e
comparison
equal deleted inserted replaced
32061:951801d8428f 32062:ada96a467a28
38 ## results if arrowsize=0.33. Since this is just a non-dimensional 38 ## results if arrowsize=0.33. Since this is just a non-dimensional
39 ## scaling factor we scale the arrowsize property value by 0.33/0.20 39 ## scaling factor we scale the arrowsize property value by 0.33/0.20
40 ## in order to get equivalent visual results while keeping equivalent 40 ## in order to get equivalent visual results while keeping equivalent
41 ## property values. 41 ## property values.
42 arrowsize = 0.20; 42 arrowsize = 0.20;
43 43 firstnonnumeric = find (cellfun ("ischar", varargin(3:nargin)), 1);
44 firstnonnumeric = find (! cellfun ("isnumeric", varargin(3:nargin)), 1);
45 if (isempty (firstnonnumeric)) 44 if (isempty (firstnonnumeric))
46 firstnonnumeric = Inf; 45 firstnonnumeric = Inf;
46
47 ## Recast non-float inputs as doubles to avoid erroneous plots.
48 varargin(3:end) = cellfun ('double', varargin(3:end), ...
49 "UniformOutput", false);
47 else 50 else
48 firstnonnumeric += 2; 51 firstnonnumeric += 2;
52
53 ## Recast non-float inputs as doubles.
54 varargin(3:firstnonnumeric-1) = cellfun ('double',
55 varargin(3:firstnonnumeric-1), "UniformOutput", false);
56
57 ## Check for scaling factor "off" and set it to 0.
58 if (strcmpi (varargin{firstnonnumeric}, "off"))
59 varargin(firstnonnumeric) = 0;
60
61 if ((firstnonnumeric) == nargin)
62 firstnonnumeric = Inf;
63 else
64 firstnonnumeric++;
65 endif
66 endif
49 endif 67 endif
50 68
51 ioff = 3; 69 ioff = 3;
52 if (nargin < (6 + is3d) || firstnonnumeric < (6 + is3d)) 70 if (nargin < (6 + is3d) || firstnonnumeric < (6 + is3d))
53 if (is3d) 71 if (is3d)