Home > atmlab > gridcreation > gridthinning.m

gridthinning

PURPOSE ^

GRIDTHINNING Removes close grid points

SYNOPSIS ^

function x = gridthinning(x0,mindx)

DESCRIPTION ^

 GRIDTHINNING   Removes close grid points 

    The input grid is thinned in such way that no points are closer than
    *mindx*. This with exceptions of the two end points that are always 
    kept, to ensure that the coverage of the grid is not decreased.

    The input grid is assumed to be increasing.

 FORMAT   x = gridthinning(x0,mindx)
        
 OUT   x       Thinned grid.
 IN    x0      Original grid
       mindx   Minimum distance in thinned grid

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gridthinning.m

SOURCE CODE ^

0001 % GRIDTHINNING   Removes close grid points
0002 %
0003 %    The input grid is thinned in such way that no points are closer than
0004 %    *mindx*. This with exceptions of the two end points that are always
0005 %    kept, to ensure that the coverage of the grid is not decreased.
0006 %
0007 %    The input grid is assumed to be increasing.
0008 %
0009 % FORMAT   x = gridthinning(x0,mindx)
0010 %
0011 % OUT   x       Thinned grid.
0012 % IN    x0      Original grid
0013 %       mindx   Minimum distance in thinned grid
0014 
0015 % 2007-05-15   Created by Patrick Eriksson.
0016 
0017 
0018 function x = gridthinning(x0,mindx)
0019 
0020   
0021 x     = x0;
0022 n     = 1;
0023 
0024 for itest = 2:length(x0)-1
0025   if x0(itest) - x(n) >= mindx
0026     n     = n + 1;
0027     x(n)  = x0(itest);
0028   end
0029 end
0030 
0031 %- Include end point
0032 %
0033 n    = n + 1; 
0034 x(n) = x0(end);
0035 
0036 
0037 x = x(1:n);

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005