借助於scipy.fft.dct()方法,我們可以通過選擇不同類型的序列來計算離散餘弦變換,並使用此方法返回變換後的數組。
用法:
scipy.fft.dct(x, type=2)
返回值:它將返回轉換後的數組。
範例1:在此示例中,我們可以看到,通過使用scipy.fft.dct()方法,我們可以通過選擇默認類型為2的不同類型的序列來獲得離散餘弦變換。
Python3
# import scipy
from scipy import fft
# Using scipy.fft.dct() method
gfg = fft.dct([1, 2, 3, 4])
print(gfg)
輸出:
[20.00000000 -6.30864406 0.00000000 -0.44834153]
範例2:
Python3
# import scipy
from scipy import fft
# Using scipy.fft.dct() method
gfg = fft.dct([-6, 5, -4, 3, -2, 1], 3)
print(gfg)
輸出:
[ -0.50866619 -0.58578644 -0.79439535 -1.34919819 -3.41421356 -29.34774027]
相關用法
- Python os._exit()用法及代碼示例
- Python os.WEXITSTATUS()用法及代碼示例
- Python os.abort()用法及代碼示例
- Python os.renames()用法及代碼示例
- Python os.lseek()用法及代碼示例
- Python calendar formatmonth()用法及代碼示例
- Python PyTorch sin()用法及代碼示例
- Python Sympy Line.is_parallel()用法及代碼示例
- Python PIL GaussianBlur()用法及代碼示例
- Python range()用法及代碼示例
- Python Numpy np.hermefit()用法及代碼示例
- Python Numpy np.hermevander()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python – scipy.fft.dct() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。