MATLAB中linspace函式使用

打呼嚕的星.發表於2020-12-11

格式:linspace(x1,x2,N)
功能:用於產生x1,x2之間的N點行向量。其中x1,x2為起始值,N為元素個數。如果預設N,預設N=100.
x=linspace(1,10,10);的效果和x=[1:1:10]類似

>> x1=[1:1:10]

x1 =

     1     2     3     4     5     6     7     8     9    10
     
 >> x2=linspace(1,10,10);
 >> x2

x2 =

     1     2     3     4     5     6     7     8     9    10
 >> x3=linspace(1,10)

x3=

  1111.0000    1.0909    1.1818    1.2727    1.3636    1.4545    1.5455    1.6364    1.7273    1.8182    1.9091

  12222.0000    2.0909    2.1818    2.2727    2.3636    2.4545    2.5455    2.6364    2.7273    2.8182    2.9091

  23333.0000    3.0909    3.1818    3.2727    3.3636    3.4545    3.5455    3.6364    3.7273    3.8182    3.9091

  34444.0000    4.0909    4.1818    4.2727    4.3636    4.4545    4.5455    4.6364    4.7273    4.8182    4.9091

  45555.0000    5.0909    5.1818    5.2727    5.3636    5.4545    5.5455    5.6364    5.7273    5.8182    5.9091

  56666.0000    6.0909    6.1818    6.2727    6.3636    6.4545    6.5455    6.6364    6.7273    6.8182    6.9091

  67777.0000    7.0909    7.1818    7.2727    7.3636    7.4545    7.5455    7.6364    7.7273    7.8182    7.9091

  78888.0000    8.0909    8.1818    8.2727    8.3636    8.4545    8.5455    8.6364    8.7273    8.8182    8.9091

  89999.0000    9.0909    9.1818    9.2727    9.3636    9.4545    9.5455    9.6364    9.7273    9.8182    9.9091

  10010.0000

相關文章