MATLAB入门之logspace(linspace)

logspace 创建指数间隔向量

%通过help命令查询logspace
>> help logspace
logspace - Generate logarithmically spaced vector

    This MATLAB function generates a row vector y of 50 logarithmically spaced
    points between decades 10^a and 10^b.

    y = logspace(a,b)
    y = logspace(a,b,n)
    y = logspace(a,pi)
%logspace(x,y) 从10^x--10^y之间生成50个元素,且50个元素构成等差数列
>> logspace(1,2)

ans =

  1 至 6 列

   10.0000   10.4811   10.9854   11.5140   12.0679   12.6486

  7 至 12 列

   13.2571   13.8950   14.5635   15.2642   15.9986   16.7683

  13 至 18 列

   17.5751   18.4207   19.3070   20.2359   21.2095   22.2300

  19 至 24 列

   23.2995   24.4205   25.5955   26.8270   28.1177   29.4705

  25 至 30 列

   30.8884   32.3746   33.9322   35.5648   37.2759   39.0694

  31 至 36 列

   40.9492   42.9193   44.9843   47.1487   49.4171   51.7947

  37 至 42 列

   54.2868   56.8987   59.6362   62.5055   65.5129   68.6649

  43 至 48 列

   71.9686   75.4312   79.0604   82.8643   86.8511   91.0298

  49 至 50 列

   95.4095  100.0000


%logspace(x,y,z) 从10^x--10^y之间生成z个元素,且z个元素构成等差数列
>> logspace(1,2,5)

ans =

   10.0000   17.7828   31.6228   56.2341  100.0000

linspace 创建规则间隔向量

%通过help命令查询linspace
>> help linspace
linspace - Generate linearly spaced vector

    This MATLAB function returns a row vector of 100 evenly spaced points between x1
    and x2.

    y = linspace(x1,x2)
    y = linspace(x1,x2,n)

%默认100个元素
>> linspace(1,3,3)

ans =

     1     2     3

你可能感兴趣的:(MATLAB,matlab)