Home > atmlab > gridcreation > grid_weightspaced.m

grid_weightspaced

PURPOSE ^

GRID_WEIGHTSPACED Creates a grid based on some response weights

SYNOPSIS ^

function g = grid_weightspaced(x,y,n)

DESCRIPTION ^

 GRID_WEIGHTSPACED   Creates a grid based on some response weights 

    This function sets up a grid where the spacing is follows some weight.
    The basic idea is that the grid shall be more dense where the response
    is high. 

    The end points of *g* equal the end points of *x*. The other points are
    determined by dividing the cumulative integral of *y* in equal steps. 

    This approach makes sense if *y* is some response function and the
    representation error where *g* will be used increases linearly with
    grid spacing.

 FORMAT   g = grid_weightspaced(x,y,n)
        
 OUT   g        Created grid.
 IN    x        Grid for *y*.
       y        Vector of weights.
       n        Number of points in *g*.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

grid_weightspaced.m

SOURCE CODE ^

0001 % GRID_WEIGHTSPACED   Creates a grid based on some response weights
0002 %
0003 %    This function sets up a grid where the spacing is follows some weight.
0004 %    The basic idea is that the grid shall be more dense where the response
0005 %    is high.
0006 %
0007 %    The end points of *g* equal the end points of *x*. The other points are
0008 %    determined by dividing the cumulative integral of *y* in equal steps.
0009 %
0010 %    This approach makes sense if *y* is some response function and the
0011 %    representation error where *g* will be used increases linearly with
0012 %    grid spacing.
0013 %
0014 % FORMAT   g = grid_weightspaced(x,y,n)
0015 %
0016 % OUT   g        Created grid.
0017 % IN    x        Grid for *y*.
0018 %       y        Vector of weights.
0019 %       n        Number of points in *g*.
0020 
0021 % 2010-09-22   Created by Patrick Eriksson.
0022 
0023 function g = grid_weightspaced(x,y,n)
0024 %
0025 if atmlab( 'STRICT_ASSERT' )
0026   rqre_datatype( x, @istensor1 );
0027   rqre_datatype( y, @istensor1 );
0028   rqre_datatype( n, @istensor0 );
0029 end
0030 
0031 cs = cumtrapz( x, abs(y) );
0032 
0033 g = interp1( cs, x, linspace( cs(1), cs(end), n ) );

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