我想将此 MATLAB 代码翻译成 Python,我想我做的一切都是正确的,即使我没有得到相同的结果。
MATLAB 脚本:
n=2   %Filter_Order
Wn=[0.4 0.6]  %# Normalized cutoff frequencies 
[b,a] = butter(n,Wn,'bandpass') % Transfer function coefficients of the filter
Run Code Online (Sandbox Code Playgroud)
蟒蛇脚本:
import numpy as np
from scipy import signal
n=2   #Filter_Order
Wn=np.array([0.4,0.6]) # Normalized cutoff frequencies 
b, a = signal.butter(n, Wn, btype='band') #Transfer function coefficients of the filter 
Run Code Online (Sandbox Code Playgroud)
a MATLAB 中的系数:  1, -5.55e-16, 1.14, -1.66e-16, 0.41
a Python中的系数: 1, -2.77e-16, 1.14, -1.94e-16, 0.41
难道这只是一个精度问题,因为两个不同的值(第二个和第四个)都在10^(-16)?!
b另一方面,系数是相同的。