tweaks
This commit is contained in:
35
scripts/string_model.py
Normal file
35
scripts/string_model.py
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
import scipy.signal as sig
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
# simple first order step response simulation
|
||||
# www.halvorsen.blog/documents/programming/python/resources/powerpoints/State Space Models with Python.pdf
|
||||
|
||||
# simulation Parameters
|
||||
x0 = [0, 0]
|
||||
start = 0
|
||||
stop = 30
|
||||
step = 1
|
||||
|
||||
t = np.arange(start,stop,step)
|
||||
K = 3
|
||||
T = 4
|
||||
|
||||
# state-space Model
|
||||
A = [[-1/T, 0], [0, 0]]
|
||||
B = [[K/T], [0]]
|
||||
C = [[1, 0]]
|
||||
D = 0
|
||||
sys = sig.StateSpace(A, B, C, D)
|
||||
|
||||
# step Response
|
||||
t, y = sig.step(sys, x0, t)
|
||||
|
||||
# plotting
|
||||
plt.plot(t, y)
|
||||
plt.title("Step Response")
|
||||
plt.xlabel("t")
|
||||
plt.ylabel("y")
|
||||
plt.grid()
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user