Home > atmlab > math > loggrid.m

loggrid

PURPOSE ^

------------------------------------------------------------------------

SYNOPSIS ^

function g = loggrid( ppoints, n_pr_decade )

DESCRIPTION ^

------------------------------------------------------------------------
 NAME:    loggrid

          Creates a vector with picewise logarithmically equally spaced 
          points. For example, LOGGRID([100 10 1],[3,2]) gives 
          [100.0000 46.4159 21.5443 10.0000 3.1623 1.0000] 

 FORMAT:  g = loggrid( ppoints, n_pr_decade )

 OUT:     g             Logarithmically spaced vector.
 IN:      ppoints       Brake points for the vector.
          n_per_decade  Number of points per decade. See the example above.
                        The length of this vector must be the length of
                        PPOINTS-1.
------------------------------------------------------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

loggrid.m

SOURCE CODE ^

0001 %------------------------------------------------------------------------
0002 % NAME:    loggrid
0003 %
0004 %          Creates a vector with picewise logarithmically equally spaced
0005 %          points. For example, LOGGRID([100 10 1],[3,2]) gives
0006 %          [100.0000 46.4159 21.5443 10.0000 3.1623 1.0000]
0007 %
0008 % FORMAT:  g = loggrid( ppoints, n_pr_decade )
0009 %
0010 % OUT:     g             Logarithmically spaced vector.
0011 % IN:      ppoints       Brake points for the vector.
0012 %          n_per_decade  Number of points per decade. See the example above.
0013 %                        The length of this vector must be the length of
0014 %                        PPOINTS-1.
0015 %------------------------------------------------------------------------
0016 
0017 % HISTORY: 2004-09-26  Copied from AMI
0018 %          2000-12-21  Created by Patrick Eriksson.
0019 
0020 
0021 function g = loggrid( ppoints, n_pr_decade )
0022 
0023 
0024 np = length( ppoints );
0025 
0026 
0027 %=== Check input
0028 if np ~= ( length(n_pr_decade) + 1 )
0029   error('The lengths of the two given vectors do not match.')
0030 end
0031 
0032 
0033 %=== Create the grid
0034 g = [];
0035 for i = 1:(np-1)
0036   n = ceil(abs(log10(ppoints(i))-log10(ppoints(i+1))) * n_pr_decade(i) + 1);
0037   g = [g;logspace(log10(ppoints(i)),log10(ppoints(i+1)),n)'];
0038 end
0039 
0040 
0041 %=== Remove points duplicated
0042 ind = find(diff(g)~=0);
0043 g   = g([ind;length(g)]);
0044

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