0001 function varargout = drawVertices(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if isAxisHandle(varargin{1})
0025 ax = varargin{1};
0026 varargin(1) = [];
0027 else
0028 ax = gca;
0029 end
0030
0031 var = varargin{1};
0032
0033
0034
0035
0036
0037 if iscell(var)
0038 N = length(var);
0039 h = zeros(N, 1);
0040 for i = 1:N
0041 state = ishold(gca);
0042 hold on;
0043
0044 if ~isempty(var{i})
0045 h(i) = drawVertices(ax, var{i}, varargin{2:end});
0046 end
0047 if ~state
0048 hold off
0049 end
0050 end
0051
0052 if nargout > 0
0053 varargout = {h};
0054 end
0055
0056 return;
0057 end
0058
0059
0060
0061
0062
0063 if size(var, 2) > 1
0064
0065 px = var(:, 1);
0066 py = var(:, 2);
0067 varargin(1) = [];
0068
0069 elseif length(varargin) >= 2 && isnumeric(varargin{1}) && isnumeric(varargin{2})
0070
0071 px = varargin{1};
0072 py = varargin{2};
0073 varargin(1:2) = [];
0074
0075 else
0076
0077 error('Should specify either a N-by-2 array, or 2 N-by-1 vectors');
0078 end
0079
0080
0081 defaults = {'MarkerSize', 6};
0082 if isscalar(varargin)
0083 varargin = [varargin defaults];
0084 else
0085 varargin = [{'ks'} defaults varargin];
0086 end
0087
0088
0089
0090
0091
0092 h = plot(ax, px, py, varargin{:});
0093
0094
0095 plot(ax, px(1), py(1), 'ks', 'MarkerFaceColor', 'k', 'MarkerSize', 8);
0096
0097
0098 if nargout > 0
0099 varargout = {h};
0100 end