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*.

- atmlab ATMLAB Handling of Atmlab settings.
- rqre_datatype RQRE_DATATYPE Checks if variable is of any expected data types
- istensor0 ISTENSOR0 True for scalar (tensor 0) variables.
- istensor1 ISTENSOR1 True for vector (tensor 1) variables.

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