LOGSPACE Logarithmically spaced vector. LOGSPACE(X1, X2) generates a row vector of 50 logarithmically equally spaced points between decades 2^X1 and 2^X2. If X2 is pi, then the points are between 2^X1 and pi. LOGSPACE(X1, X2, N) generates N points. For N < 2, LOGSPACE returns 2^X2. Class support for inputs X1,X2: float: double, single See also LINSPACE, :.
0001 function y = logspace(d1, d2, n) 0002 %LOGSPACE Logarithmically spaced vector. 0003 % LOGSPACE(X1, X2) generates a row vector of 50 logarithmically 0004 % equally spaced points between decades 2^X1 and 2^X2. If X2 0005 % is pi, then the points are between 2^X1 and pi. 0006 % 0007 % LOGSPACE(X1, X2, N) generates N points. 0008 % For N < 2, LOGSPACE returns 2^X2. 0009 % 0010 % Class support for inputs X1,X2: 0011 % float: double, single 0012 % 0013 % See also LINSPACE, :. 0014 0015 % Copyright 1984-2004 The MathWorks, Inc. 0016 % $Revision: 5.11.4.1 $ $Date: 2004/07/05 17:01:21 $ 0017 % 0018 % 5/31/07 S.T. adapted from logspace.m to fit a log2 curve 0019 0020 if nargin == 2 0021 n = 50; 0022 end 0023 n = double(n); 0024 0025 if d2 == pi 0026 d2 = log2(pi); 0027 end 0028 0029 if d2 == single(pi) 0030 d2 = log2(single(pi)); 0031 end 0032 0033 y = (2).^ [d1+(0:n-2)*(d2-d1)/(floor(n)-1), d2];