Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions control/modelsimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,21 +667,21 @@ def markov(*args, m=None, transpose=False, dt=None, truncate=False):

# Set up the full problem
# Create matrix of (shifted) inputs
UUT = np.zeros((p*m,(l)))
UUT = np.zeros((p*m, l))
for i in range(m):
# Shift previous column down and keep zeros at the top
UUT[i*p:(i+1)*p,i:] = Umat[:,:l-i]
UUT[i*p:(i+1)*p, i:] = Umat[:, :l-i]

# Truncate first t=0 or t=m time steps, transpose the problem for lsq
YY = Ymat[:,t:].T
UU = UUT[:,t:].T
YY = Ymat[:, t:].T
UU = UUT[:, t:].T

# Solve for the Markov parameters from YY = UU @ H.T
HT, _, _, _ = np.linalg.lstsq(UU, YY, rcond=None)
H = HT.T/dt # scaling

H = H.reshape(q,m,p) # output, time*input -> output, time, input
H = H.transpose(0,2,1) # output, input, time
H = H.reshape(q, m, p) # output, time*input -> output, time, input
H = H.transpose(0, 2, 1) # output, input, time

# for siso return a 1D array instead of a 3D array
if q == 1 and p == 1:
Expand Down
2 changes: 1 addition & 1 deletion control/tests/docstrings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
control.ss2tf: '48ff25d22d28e7b396e686dd5eb58831',
control.tf: '53a13f4a7f75a31c81800e10c88730ef',
control.tf2ss: '086a3692659b7321c2af126f79f4bc11',
control.markov: '753309de348132ef238e78ac756412c1',
control.markov: 'eda7c4635bbb863ae6659e574285d356',
control.gangof4: '0e52eb6cf7ce024f9a41f3ae3ebf04f7',
}

Expand Down
Loading