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 slnums2bounds
Home > sltoolbox > utils > slnums2bounds.m

slnums2bounds

PURPOSE ^

SLNUMS2BOUNDS Compute the index-boundaries from section sizes

SYNOPSIS ^

function [spos, epos] = slnums2bounds(nums)

DESCRIPTION ^

SLNUMS2BOUNDS Compute the index-boundaries from section sizes

 $ Syntax $
   - [spos, epos] = slnums2bounds(nums)
   - spos = slnums2bounds(nums)

 $ Description $
   - [spos, epos] = slnums2bounds(nums) obtains the start positions and
     end positions of the sections given the number of elements in 
     the sections.

   - spos = slnums2bounds(nums) only retrieves the start positions.

 $ Reamrks $
   # nums can be either a row vector or a column vector. then the results
     will be row vector or column vector correspondingly.

 $ Examples $
   - Get boundaries for a 3-section-array
     \{
           [s, e] = slnums2bounds([3 2 4])

           s = 
                1     4     6
           e =
                3     5     9
     \}

 $ History $
   - Created by Dahua Lin on Nov 20th, 2005

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • sledgeset2adjlist SLEDGESET2ADJLIST Converts edge set to adjacency list
  • slpruneedgeset SLPRUNEEDGESET Prunes the edge set
  • slgda SLGDA Performs Baudat's Generalized Discriminant Analysis
  • sllogistreg SLLOGISTREG Performs Multivariate Logistic Regression
  • slcovs SLCOVS Computes the sample covariance matrix
  • slmeans SLMEANS Compute the mean vectors
  • slposterioritrue SLPOSTERIORITRUE Computes the posteriori that samples belong to true class
  • sldlda SLDLDA Performs Direct Linear Discriminant Analysis
  • slfld SLFLD Performs Fisher Linear Discriminant Analysis
  • slnlda SLNLDA Performs Nullspace-based Linear Discriminant Analysis
  • slscatter SLSCATTER Compute the scatter matrix
  • sllabelinds SLLABELINDS Extract indices corresponding to specified labels
  • sldrawpts SLDRAWPTS Draws a set of sample points on axes

SOURCE CODE ^

0001 function [spos, epos] = slnums2bounds(nums)
0002 %SLNUMS2BOUNDS Compute the index-boundaries from section sizes
0003 %
0004 % $ Syntax $
0005 %   - [spos, epos] = slnums2bounds(nums)
0006 %   - spos = slnums2bounds(nums)
0007 %
0008 % $ Description $
0009 %   - [spos, epos] = slnums2bounds(nums) obtains the start positions and
0010 %     end positions of the sections given the number of elements in
0011 %     the sections.
0012 %
0013 %   - spos = slnums2bounds(nums) only retrieves the start positions.
0014 %
0015 % $ Reamrks $
0016 %   # nums can be either a row vector or a column vector. then the results
0017 %     will be row vector or column vector correspondingly.
0018 %
0019 % $ Examples $
0020 %   - Get boundaries for a 3-section-array
0021 %     \{
0022 %           [s, e] = slnums2bounds([3 2 4])
0023 %
0024 %           s =
0025 %                1     4     6
0026 %           e =
0027 %                3     5     9
0028 %     \}
0029 %
0030 % $ History $
0031 %   - Created by Dahua Lin on Nov 20th, 2005
0032 %
0033 
0034 %% parse and verify input arguments
0035 [d1, d2] = size(nums);
0036 if d1 == 1          % row vector
0037     iscol = false;
0038 elseif d2 == 1      % column vector
0039     iscol = true;
0040 else
0041     error('sltoolbox:notvector', 'nums should be a row/column vector');
0042 end
0043     
0044 
0045 %% compute
0046 cs = cumsum(nums);
0047 if iscol
0048     spos = [1; cs(1:end-1)+1];
0049 else
0050     spos = [1, cs(1:end-1)+1];
0051 end
0052 if nargout >= 2
0053     epos = cs;
0054 end
0055 
0056     
0057

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

Contact us at files@mathworks.com