當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python scipy.fft.dst()用法及代碼示例

借助scipy.fft.dst()方法,我們可以通過選擇不同類型的序列來計算離散正弦變換,並使用此方法返回變換後的數組。

用法:

scipy.fft.dst(x, type=2)

返回值:它將返回轉換後的數組。

範例1:在此示例中,我們可以看到,通過使用scipy.fft.dst()方法,我們可以通過默認選擇2種不同類型的序列來獲得離散正弦變換。



Python3

# import scipy 
from scipy import fft 
  
# Using scipy.fft.dst() method 
gfg = fft.dst([1, 2, 3, 4]) 
  
print(gfg)

輸出:

[13.06562965 -5.65685425  5.41196100 -4.00000000]

範例2:

Python3

# import scipy 
from scipy import fft 
  
# Using scipy.fft.dst() method 
gfg = fft.dst([-6, 5, -4, 3, -2, 1], 3) 
  
print(gfg)

輸出:

[ -1.43023367  -2.3137085   -6.16568427  -7.77337942 -20.3137085
 -23.82253852]

相關用法


注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python – scipy.fft.dst() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。