Home > FMAToolbox > Helpers > glinspace.m

glinspace

PURPOSE ^

glinspace - Gamma-corrected linearly spaced vector.

SYNOPSIS ^

function x = glinspace(d1,d2,gamma,n)

DESCRIPTION ^

glinspace - Gamma-corrected linearly spaced vector.

  USAGE

    x = glinspace(d1,d2,gamma,n)

    d1             start value
    d2             stop value
    gamma          gamma value
    n              number of values

  SEE ALSO

    See also linspace.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %glinspace - Gamma-corrected linearly spaced vector.
0002 %
0003 %  USAGE
0004 %
0005 %    x = glinspace(d1,d2,gamma,n)
0006 %
0007 %    d1             start value
0008 %    d2             stop value
0009 %    gamma          gamma value
0010 %    n              number of values
0011 %
0012 %  SEE ALSO
0013 %
0014 %    See also linspace.
0015 %
0016 
0017 % Copyright (C) 2013 by Michaƫl Zugaro
0018 %
0019 % This program is free software; you can redistribute it and/or modify
0020 % it under the terms of the GNU General Public License as published by
0021 % the Free Software Foundation; either version 3 of the License, or
0022 % (at your option) any later version.
0023 
0024 function x = glinspace(d1,d2,gamma,n)
0025 
0026 % Check number of parameters
0027 if nargin < 3,
0028   error('Incorrect number of parameters (type ''help <a href="matlab:help glinspace">glinspace</a>'' for details).');
0029 end
0030 
0031 % Check parameters
0032 if ~isdscalar(d1),
0033   error('Incorrect start value (type ''help <a href="matlab:help glinspace">glinspace</a>'' for details).');
0034 end
0035 if ~isdscalar(d2),
0036   error('Incorrect stop value (type ''help <a href="matlab:help glinspace">glinspace</a>'' for details).');
0037 end
0038 if ~isdscalar(gamma) || gamma <= 0,
0039   error('Incorrect start value (type ''help <a href="matlab:help glinspace">glinspace</a>'' for details).');
0040 end
0041 if nargin < 3,
0042     n = 100;
0043 end
0044 if ~isiscalar(n),
0045   error('Incorrect number of values (type ''help <a href="matlab:help glinspace">glinspace</a>'' for details).');
0046 end
0047 
0048 if d1 > d2
0049     gamma = 1/gamma;
0050 end
0051 
0052 x = linspace(0,1,n) .^ (1/gamma);
0053 x = x *(d2-d1) + d1;

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005