我嘗試用list把x添加到list里面,但是輸出是[matrix([[0.37160519]]), matrix([[0.37160091]]), matrix([[0.37159685]]), matrix([[0.371593]]), matrix([[0.37158934]]), matrix([[0.37158587]]), matrix([[0.37158256]]), matrix([[0.3715794]]), matrix([[0.37157639]]), matrix([[0.37157351]]), matrix([[0.37157076]]), matrix([[0.37156813]]), matrix([[0.37156561]]), matrix([[0.37156319]]), matrix([[0.37156086]]), matrix([[0.37155863]])],怎么樣才能把得到的X畫到一張圖里呢?謝謝
"""
2019.11.16
Kalman Filter-ASN course
Zhaoxueqi
"""
import numpy as np
import matplotlib.pyplot as plt
def kf(Z, x, P, H, R, u, A, Q):
K_temp = K = 0
list_x = []
list_y = []
for i in range(50):
K_temp = K
x = A * x
P = A * P * A.T + Q
K = P * H.T * np.linalg.inv(H * P * H.T + R)
if(K_temp == K):
break
x = x + K * (Z - H * x)
P = (np.eye(K.shape[0]) - K * H) * P
y = i
list_x.append(x)
list_y.append(y)
plt.plot(y, x)
print(list_x)
print(list_y)
plt.show()
A = np.matrix([1])
H = np.matrix([1])
u = 0
x = 0.37842
Z = H * x + np.random.normal(0, 0.01, 1) # Zk having noise with N(0,4), H = 1
R = 0.81
P = 1
Q = 0
kf(Z, x, P, H, R, u, A, Q)
uj5u.com熱心網友回復:
首先你要找一個可以進行位圖操作的圖形庫,然后以點陣方式寫入每個像素點的顏色值轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/127554.html
