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):
368
368
369
369
return K , S , E
370
370
371
- def ctrb (A ,B ):
371
+ def ctrb (A , B ):
372
372
"""Controllabilty matrix
373
373
374
374
Parameters
@@ -391,10 +391,9 @@ def ctrb(A,B):
391
391
amat = np .mat (A )
392
392
bmat = np .mat (B )
393
393
n = np .shape (amat )[0 ]
394
+
394
395
# 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 )])
398
397
return ctrb
399
398
400
399
def obsv (A , C ):
@@ -421,10 +420,8 @@ def obsv(A, C):
421
420
cmat = np .mat (C )
422
421
n = np .shape (amat )[0 ]
423
422
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 )])
428
425
return obsv
429
426
430
427
def gram (sys ,type ):
You can’t perform that action at this time.
0 commit comments