File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ def lqr(*args, **keywords):
368368
369369 return K , S , E
370370
371- def ctrb (A ,B ):
371+ def ctrb (A , B ):
372372 """Controllabilty matrix
373373
374374 Parameters
@@ -391,10 +391,9 @@ def ctrb(A,B):
391391 amat = np .mat (A )
392392 bmat = np .mat (B )
393393 n = np .shape (amat )[0 ]
394+
394395 # Construct the controllability matrix
395- ctrb = bmat
396- for i in range (1 , n ):
397- ctrb = np .hstack ((ctrb , amat ** i * bmat ))
396+ ctrb = np .hstack ([bmat ] + [amat ** i * bmat for i in range (1 , n )])
398397 return ctrb
399398
400399def obsv (A , C ):
@@ -421,10 +420,8 @@ def obsv(A, C):
421420 cmat = np .mat (C )
422421 n = np .shape (amat )[0 ]
423422
424- # Construct the controllability matrix
425- obsv = cmat
426- for i in range (1 , n ):
427- obsv = np .vstack ((obsv , cmat * amat ** i ))
423+ # Construct the observability matrix
424+ obsv = np .vstack ([cmat ] + [cmat * amat ** i for i in range (1 , n )])
428425 return obsv
429426
430427def gram (sys ,type ):
You can’t perform that action at this time.
0 commit comments