Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of sldrawmanipts
Home > sltoolbox > visualize > sldrawmanipts.m

sldrawmanipts

PURPOSE ^

SLDRAWMANIPTS Draws the sample points on a manifold

SYNOPSIS ^

function [h, cm] = sldrawmanipts(X, s, crspec)

DESCRIPTION ^

SLDRAWMANIPTS Draws the sample points on a manifold

 $ Syntax $
   - sldrawmanipts(X)
   - sldrawmanipts(X, s, crspec)
   - h = sldrawmanipts(X, s, crspec)
   - [h, cm] = sldrawmanipts(X, s, crspec)

 $ Arguments $
   - X:        The sample matrix (2 x n or 3 x n)
   - s:        The scalar indicating the marker size (default = 5)
   - crspec:   The specification of the colors, can be in either of the
               following forms:
               - a string (plot symbol) indicating a basic color
               - a 1 x n row vector as a color map
               - a function handle to calculate the color map
                   c = f(x, y) for 2D samples
                   c = f(x, y, z) for 3D samples
               default = 'b';
   - h:        The handles to the drawn objects
   - cm:       The color map used
 
 $ History $
   - Created by Dahua Lin, on Sep 9, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:

SOURCE CODE ^

0001 function [h, cm] = sldrawmanipts(X, s, crspec)
0002 %SLDRAWMANIPTS Draws the sample points on a manifold
0003 %
0004 % $ Syntax $
0005 %   - sldrawmanipts(X)
0006 %   - sldrawmanipts(X, s, crspec)
0007 %   - h = sldrawmanipts(X, s, crspec)
0008 %   - [h, cm] = sldrawmanipts(X, s, crspec)
0009 %
0010 % $ Arguments $
0011 %   - X:        The sample matrix (2 x n or 3 x n)
0012 %   - s:        The scalar indicating the marker size (default = 5)
0013 %   - crspec:   The specification of the colors, can be in either of the
0014 %               following forms:
0015 %               - a string (plot symbol) indicating a basic color
0016 %               - a 1 x n row vector as a color map
0017 %               - a function handle to calculate the color map
0018 %                   c = f(x, y) for 2D samples
0019 %                   c = f(x, y, z) for 3D samples
0020 %               default = 'b';
0021 %   - h:        The handles to the drawn objects
0022 %   - cm:       The color map used
0023 %
0024 % $ History $
0025 %   - Created by Dahua Lin, on Sep 9, 2006
0026 %
0027 
0028 %% parse and verify arguments
0029 
0030 if ndims(X) ~= 2 
0031     error('sltoolbox:invalidarg', ...
0032         'The sample matrix X should be a 2D matrix');
0033 end
0034 
0035 [d, n] = size(X);
0036 if d ~= 2 && d ~= 3
0037     error('sltoolbox:invalidarg', ...
0038         'The samples should be 2D or 3D');
0039 end
0040 if d == 2
0041     x = X(1, :);
0042     y = X(2, :);
0043 else
0044     x = X(1, :);
0045     y = X(2, :);
0046     z = X(3, :);
0047 end
0048 
0049 if nargin < 2 || isempty(s)
0050     s = 5;
0051 else    
0052     if ~isscalar(s)
0053         error('sltoolbox:invalidarg', ...
0054             's should be a scalar');
0055     end
0056 end
0057 
0058 if nargin < 3 || isempty(crspec)
0059     cm = 'b';
0060 else
0061     if ischar(crspec)
0062         cm = crspec;
0063     elseif isnumeric(crspec)
0064         if ~isequal(size(crspec), [1,n])
0065             error('sltoolbox:sizmismatch', ...
0066                 'The size of the color map is not consistent with the sample number');
0067         end
0068         cm = crspec;
0069     elseif isa(crspec, 'function_handle')
0070         if d == 2
0071             cm = crspec(x, y);
0072         else
0073             cm = crspec(x, y, z);
0074         end
0075     else
0076         error('sltoolbox:invalidarg', ...
0077             'crspec should be a string, a row vector or a function handle');
0078     end
0079 end
0080 
0081 %% draw
0082 
0083 if d == 2
0084     if nargout == 0
0085         scatter(x, y, s, cm);
0086     else
0087         h = scatter(x, y, s, cm);
0088     end
0089 else
0090     if nargout == 0
0091         scatter3(x, y, z, s, cm);
0092     else
0093         h = scatter3(x, y, z, s, cm);
0094     end
0095 end
0096         
0097     
0098 
0099 
0100 
0101 
0102 
0103

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com