0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】linspace関数

Posted at

linspace関数は指定した範囲の要素を等間隔に区切り、floatの配列を返します。引数は「開始、終了、間隔」の順で、インデックスと違って「終了」の値も含みます。

引数で分割数を指定しなかった場合は、デフォルトの「50分割」が適用されます。例えば「np.linspace(-np.pi, np.pi)」とすると、-3.14159235〜3.14159235の範囲で50等分した要素が返ります。これをsin関数の引数にしてグラフにすると、次の周期グラフになります。

x = np.linspace(-np.pi, np.pi)
y = np.sin(x)
plt.plot(x, y)

image.png

x軸がlinspace関数で生成した50個の要素で、y軸がその要素を引数としたsin関数の結果(三角比)です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?