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

slgridsamples

PURPOSE ^

SLGRIDSAMPLES Generate the sample vectors on grid points

SYNOPSIS ^

function X = slgridsamples(varargin)

DESCRIPTION ^

SLGRIDSAMPLES Generate the sample vectors on grid points
 
 $ Syntax $
   - X = slgridsamples(x1, x2, ..., xd)
   - X = slgridsamples({x1, x2, ..., xd}) 

 $ Description $
   - X = slgridsamples(x1, x2, ..., xd) generates a d x (n1xn2x...xnd)
     sample matrix, provided that x1, x2, ... xd are vectors storing the
     the sampled values along dimensions with lengths n1, n2, ..., nd.

   - X = slgridsamples({x1, x2, ..., xd}) is similar to the previous 
     syntax, except that the dimension sample value vectors are groupped
     into a cell array.

 $ Remarks $
   - The orders of the samples are determined in following manner that
     the indices of the grids are generated by slallcombs.
   - If input arguments are empty, the resulting X would be empty.

 $ History $
   - Created by Dahua Lin on Dec 28th, 2005

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slallcombs SLALLCOMBS Generate all combination of numbers
This function is called by:

SOURCE CODE ^

0001 function X = slgridsamples(varargin)
0002 %SLGRIDSAMPLES Generate the sample vectors on grid points
0003 %
0004 % $ Syntax $
0005 %   - X = slgridsamples(x1, x2, ..., xd)
0006 %   - X = slgridsamples({x1, x2, ..., xd})
0007 %
0008 % $ Description $
0009 %   - X = slgridsamples(x1, x2, ..., xd) generates a d x (n1xn2x...xnd)
0010 %     sample matrix, provided that x1, x2, ... xd are vectors storing the
0011 %     the sampled values along dimensions with lengths n1, n2, ..., nd.
0012 %
0013 %   - X = slgridsamples({x1, x2, ..., xd}) is similar to the previous
0014 %     syntax, except that the dimension sample value vectors are groupped
0015 %     into a cell array.
0016 %
0017 % $ Remarks $
0018 %   - The orders of the samples are determined in following manner that
0019 %     the indices of the grids are generated by slallcombs.
0020 %   - If input arguments are empty, the resulting X would be empty.
0021 %
0022 % $ History $
0023 %   - Created by Dahua Lin on Dec 28th, 2005
0024 %
0025 
0026 %% parse and verify input arguments
0027 if nargin == 0
0028     X = [];
0029     return;
0030 end
0031 if iscell(varargin{1})
0032     vars = varargin{1};
0033 else
0034     vars = varargin;
0035 end
0036 
0037 %% Prepare
0038 d = length(vars);
0039 ns = zeros(1, d);
0040 for i = 1 : d
0041     ns(i) = length(vars{i});
0042 end
0043 ntotal = prod(ns);
0044 X = zeros(d, ntotal);
0045 if ntotal == 0
0046     return;
0047 end
0048 
0049 %% Genertae
0050 inds = slallcombs(ns);
0051 for i = 1 : d
0052     X(i, :) = vars{i}(inds(i, :));
0053 end
0054 
0055 
0056 
0057     
0058

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

Contact us at files@mathworks.com