x[t+1] = -6*x[t] - 9*y[t] + 4
y[t+1] = x[t]
我想用python的符号方式来解决这个差分方程组,就像sympydo的rsolve:Here
但我只能这样画:
import numpy as np
import matplotlib.pyplot as plt
from sympy import init_printing
init_printing()
T = 71
x = np.zeros(T)
x[0] = 1
y = np.zeros(T)
y[0] = 1
for t in range(T-1):
x[t+1] = -6*x[t] - 9*y[t] + 4
y[t+1] = x[t]
fig = plt.figure(figsize=(12,4))
ax = fig.add_subplot(1,2,1)
ax.plot(x,lw=3,alpha=0.75)
ax.set_title('x')
ax.grid()
ax = fig.add_subplot(1,2,2)
ax.plot(y,lw=3,alpha=0.75)
ax.set_title('y')
ax.grid()
rsolve只解一个递推方程,我想把它们作为一个系统来解。有办法做到这一点吗
目前没有回答
相关问题 更多 >
编程相关推荐