diff --git a/control/modelsimp.py b/control/modelsimp.py index d2eadc4c3..be9949374 100644 --- a/control/modelsimp.py +++ b/control/modelsimp.py @@ -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: diff --git a/control/tests/docstrings_test.py b/control/tests/docstrings_test.py index 28bd0f38c..70a0cc3c1 100644 --- a/control/tests/docstrings_test.py +++ b/control/tests/docstrings_test.py @@ -39,7 +39,7 @@ control.ss2tf: '48ff25d22d28e7b396e686dd5eb58831', control.tf: '53a13f4a7f75a31c81800e10c88730ef', control.tf2ss: '086a3692659b7321c2af126f79f4bc11', - control.markov: '753309de348132ef238e78ac756412c1', + control.markov: 'eda7c4635bbb863ae6659e574285d356', control.gangof4: '0e52eb6cf7ce024f9a41f3ae3ebf04f7', }