基于python實(shí)現(xiàn)matlab filter函數(shù)過程詳解
matlab中的filter函數(shù):
y = filter(b,a,x)
python實(shí)現(xiàn)matlab中的filter函數(shù)
def filter_matlab(b,a,x): y = [] y.append(b[0] * x[0]) for i in range(1,len(x)): y.append(0) for j in range(len(b)): if i >= j :y[i] = y[i] + b[j] * x[i - j ]j += 1 for l in range(len(b)-1 ): if i >l:y[i] = (y[i] - a[l+1] * y[i -l-1])l += 1 i += 1 return y
example:
取
b = [8,-3.5,0.5]a = [1,-1.5,0.25]x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]y = filter_matlab(b,a,x)
函數(shù)的結(jié)果和matlab的filter函數(shù)結(jié)果一致,為
[8, 24.5, 52.25, 94.75, 156.5625, 243.65625, 363.84375, 527.3515625, 747.56640625, 1042.01171875, 1433.6259765625, 1952.43603515625, 2637.74755859375, 3541.0123291015625, 4729.581604003906, 6291.619323730469, 8342.533584594727, 11033.395545959473, 14561.959922790527, 19187.090997695923]
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. CSS hack用法案例詳解2. asp中response.write("中文")或者js中文亂碼問題3. JSP servlet實(shí)現(xiàn)文件上傳下載和刪除4. ASP中格式化時(shí)間短日期補(bǔ)0變兩位長日期的方法5. 詳解瀏覽器的緩存機(jī)制6. 怎樣才能用js生成xmldom對象,并且在firefox中也實(shí)現(xiàn)xml數(shù)據(jù)島?7. input submit、button和回車鍵提交數(shù)據(jù)詳解8. 怎樣打開XML文件?xml文件如何打開?9. 詳解盒子端CSS動(dòng)畫性能提升10. css代碼優(yōu)化的12個(gè)技巧
