File: control.texi

package info (click to toggle)
octave-control 1.0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,628 kB
  • ctags: 160
  • sloc: makefile: 64; sh: 4
file content (4961 lines) | stat: -rw-r--r-- 115,076 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
\input texinfo

@setfilename control.info

@settitle Octave Control Systems Toolbox (@acronym{OCST})

@titlepage
@title  Octave Control Systems Toolbox (@acronym{OCST})
@subtitle Version 1.0.0
@subtitle July 2008
@author Dr A Scottedward Hodel
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 2008 A Scottedward Hodel

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the same conditions as for modified versions.
@end titlepage

@contents

@ifinfo
@node Top, Introduction
@top
@end ifinfo

@menu
* Introduction:: Introduction
* sysstruct:: System Data Structure
* sysinterface:: System Construction and Interface Functions
* sysdisp:: System display functions
* blockdiag:: Block Diagram Manipulations
* numerical:: Numerical Functions
* sysprop:: System Analysis-Properties
* systime:: System Analysis-Time Domain
* sysfreq:: System Analysis-Frequency Domain
* cacsd:: Controller Design
* misc:: Miscellaneous Functions (Not yet properly filed/documented)
@end menu

@node Introduction
@chapter Introduction

The Octave Control Systems Toolbox (@acronym{OCST}) was initially developed
by Dr.@: A. Scottedward Hodel 
@email{a.s.hodel@@eng.auburn.edu} with the assistance
of his students
@itemize @bullet
@item R. Bruce Tenison @email{btenison@@dibbs.net}, 
@item David C. Clem,
@item John E. Ingram @email{John.Ingram@@sea.siemans.com}, and 
@item Kristi McGowan.  
@end itemize
This development was supported in part by @acronym{NASA}'s Marshall Space Flight 
Center as part of an in-house @acronym{CACSD} environment.  Additional important 
contributions were made by Dr. Kai Mueller @email{mueller@@ifr.ing.tu-bs.de}
and Jose Daniel Munoz Frias (@code{place.m}).

An on-line menu-driven tutorial is available via @code{DEMOcontrol};
beginning @acronym{OCST} users should start with this program. 

@deftypefn {Function File} {} DEMOcontrol
Octave Control Systems Toolbox demo/tutorial program.  The demo
allows the user to select among several categories of @acronym{OCST} function:
@example
@group
octave:1> DEMOcontrol
Octave Controls System Toolbox Demo

[ 1] System representation
[ 2] Block diagram manipulations
[ 3] Frequency response functions
[ 4] State space analysis functions
[ 5] Root locus functions
[ 6] LQG/H2/Hinfinity functions
[ 7] End
@end group
@end example
Command examples are interactively run for users to observe the use
of @acronym{OCST} functions
See also: bddemo, frdemo, analdemo, moddmeo, rldemo
@end deftypefn



@menu
* sysstruct::                   
* sysinterface::                
* sysdisp::                     
* blockdiag::                   
* numerical::                   
* sysprop::                     
* systime::                     
* sysfreq::                     
* cacsd::                       
* misc::                        
@end menu

@node sysstruct
@chapter System Data Structure

@menu
* sysstructvars::               
* sysstructtf::                 
* sysstructzp::                 
* sysstructss::                 
@end menu

The @acronym{OCST} stores all dynamic systems in
a single data structure format that can represent continuous systems,
discrete-systems, and mixed (hybrid) systems in state-space form, and
can also represent purely continuous/discrete systems in either
transfer function or pole-zero form. In order to
provide more flexibility in treatment of discrete/hybrid systems, the
@acronym{OCST} also keeps a record of which system outputs are sampled.

Octave structures are accessed with a syntax much like that used
by the C programming language.  For consistency in
use of the data structure used in the @acronym{OCST}, it is recommended that
the system structure access m-files be used (@pxref{sysinterface}).
Some elements of the data structure are absent depending on the internal
system representation(s) used.  More than one system representation
can be used for @acronym{SISO} systems; the @acronym{OCST} m-files ensure that all representations
used are consistent with one another.

@deftypefn {Function File} {} sysrepdemo
Tutorial for the use of the system data structure functions
@end deftypefn



@node sysstructvars
@section Variables common to all @acronym{OCST} system formats

The data structure elements (and variable types) common to all  system
representations are listed below; examples of the initialization
and use of the system data structures are given in subsequent sections and
in the online demo @code{DEMOcontrol}.
@table @var
@item n
@itemx nz
The respective number of continuous and discrete states
in the system (scalar)

@item inname
@itemx outname
list of name(s) of the system input, output signal(s). (list of strings)

@item sys
System status vector.  (vector)

This vector indicates both what representation was used to initialize
the system data structure (called the primary system type) and which
other representations are currently up-to-date with the primary system
type (@pxref{structaccess}).

The value of the first element of the vector indicates the primary
system type.

@table @asis
@item 0
for tf form (initialized with @code{tf2sys} or @code{fir2sys})

@item 1
for zp form (initialized with @code{zp2sys})

@item 2
for ss form (initialized with @code{ss2sys})
@end table

The next three elements are boolean flags that indicate whether tf, zp,
or ss, respectively, are ``up to date" (whether it is safe to use the
variables associated with these representations).  These flags are
changed when calls are made to the @code{sysupdate} command.

@item tsam
 Discrete time sampling period  (nonnegative scalar).
 @var{tsam} is set to 0 for continuous time systems.

@item yd
 Discrete-time output list (vector)

 indicates which outputs are discrete time (i.e.,
    produced by D/A converters) and which are continuous time.
    yd(ii) = 0 if output ii is continuous, = 1 if discrete.
@end table

The remaining variables of the  system data structure are only present
if the corresponding entry of the @code{sys} vector is true (=1).

@node sysstructtf
@section @code{tf} format variables

@table @var
@item num
 numerator coefficients   (vector)

@item den
 denominator coefficients   (vector)

@end table

@node sysstructzp
@section @code{zp} format variables

@table @var
@item zer
 system zeros   (vector)

@item pol
 system poles    (vector)

@item k
 leading coefficient   (scalar)

@end table

@node sysstructss
@section @code{ss} format variables

@table @var
@item a
@itemx b
@itemx c
@itemx d
The usual state-space matrices. If a system has both
        continuous and discrete states, they are sorted so that
        continuous states come first, then discrete states

@strong{Note} some functions (e.g., @code{bode}, @code{hinfsyn}) 
will not accept systems with both discrete and continuous states/outputs

@item stname
names of system states   (list of strings)

@end table

@node sysinterface
@chapter System Construction and Interface Functions

Construction and manipulations of the @acronym{OCST} system data structure
(@pxref{sysstruct}) requires attention to many details in order
to ensure that data structure contents remain consistent.  Users
are strongly encouraged to use the system interface functions
in this section.  Functions for the formatted display in of system
data structures are given in @ref{sysdisp}.

@menu
* fir2sys::                     
* ss2sys::                      
* tf2sys::                      
* zp2sys::                      
* structaccess::                
@end menu

@node fir2sys
@section Finite impulse response system interface functions

@deftypefn {Function File} {} fir2sys (@var{num}, @var{tsam}, @var{inname}, @var{outname})
construct a system data structure from @acronym{FIR} description

@strong{Inputs}
@table @var
@item num
vector of coefficients
@ifinfo
[c0, c1, @dots{}, cn]
@end ifinfo
@iftex
@tex
$ [c_0, c_1, \ldots, c_n ]$
@end tex
@end iftex
of the @acronym{SISO} @acronym{FIR} transfer function
@ifinfo
C(z) = c0 + c1*z^(-1) + c2*z^(-2) + @dots{} + cn*z^(-n)
@end ifinfo
@iftex
@tex
$$ C(z) = c_0 + c_1z^{-1} + c_2z^{-2} + \ldots + c_nz^{-n} $$
@end tex
@end iftex

@item tsam
sampling time (default: 1)

@item inname
name of input signal;  may be a string or a list with a single entry

@item outname
name of output signal; may be a string or a list with a single entry
@end table

@strong{Output}
@table @var
@item sys
system data structure
@end table

@strong{Example}
@example
octave:1> sys = fir2sys([1 -1 2 4],0.342,\
> "A/D input","filter output");
octave:2> sysout(sys)
Input(s)
1: A/D input

Output(s):
1: filter output (discrete)

Sampling interval: 0.342
transfer function form:
1*z^3 - 1*z^2 + 2*z^1 + 4
-------------------------
1*z^3 + 0*z^2 + 0*z^1 + 0
@end example
@end deftypefn



@deftypefn {Function File} {[@var{c}, @var{tsam}, @var{input}, @var{output}] =} sys2fir (@var{sys})

Extract @acronym{FIR} data from system data structure; see @command{fir2sys} for
parameter descriptions
See also: fir2sys
@end deftypefn



@node ss2sys
@section State space system interface functions

@deftypefn {Function File} {@var{outsys} =} ss (@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{outlist})
Create system structure from state-space data.   May be continuous,
discrete, or mixed (sampled data)

@strong{Inputs}
@table @var
@item a
@itemx b
@itemx c
@itemx d
usual state space matrices

default: @var{d} = zero matrix

@item   tsam
sampling rate.  Default: @math{tsam = 0} (continuous system)

@item n
@itemx nz
number of continuous, discrete states in the system

If @var{tsam} is 0, @math{n = @code{rows}(@var{a})}, @math{nz = 0}

If @var{tsam} is greater than zero, @math{n = 0},
@math{nz = @code{rows}(@var{a})}

see below for system partitioning

@item  stname
cell array of strings of state signal names

default (@var{stname}=[] on input): @code{x_n} for continuous states,
@code{xd_n} for discrete states

@item inname
cell array of strings of input signal names

default (@var{inname} = [] on input): @code{u_n}

@item outname
cell array of strings of output signal names

default (@var{outname} = [] on input): @code{y_n}

@item   outlist

list of indices of outputs y that are sampled

If @var{tsam} is 0, @math{outlist = []}

If @var{tsam} is greater than 0, @math{outlist = 1:@code{rows}(@var{c})}
@end table

Unlike states, discrete/continuous outputs may appear in any order

@code{sys2ss} returns a vector @var{yd} where
@var{yd}(@var{outlist}) = 1; all other entries of @var{yd} are 0

@strong{Output}
@table @var
@item outsys
system data structure
@end table

@strong{System partitioning}

Suppose for simplicity that outlist specified
that the first several outputs were continuous and the remaining outputs
were discrete.  Then the system is partitioned as
@example
@group
x = [ xc ]  (n x 1)
[ xd ]  (nz x 1 discrete states)
a = [ acc acd ]  b = [ bc ]
[ adc add ]      [ bd ]
c = [ ccc ccd ]  d = [ dc ]
[ cdc cdd ]      [ dd ]

(cdc = c(outlist,1:n), etc.)
@end group
@end example
with dynamic equations:
@ifinfo
@math{d/dt xc(t)     = acc*xc(t)      + acd*xd(k*tsam) + bc*u(t)}

@math{xd((k+1)*tsam) = adc*xc(k*tsam) + add*xd(k*tsam) + bd*u(k*tsam)}

@math{yc(t)      = ccc*xc(t)      + ccd*xd(k*tsam) + dc*u(t)}

@math{yd(k*tsam) = cdc*xc(k*tsam) + cdd*xd(k*tsam) + dd*u(k*tsam)}
@end ifinfo
@iftex
@tex
$$\eqalign{
{d \over dt} x_c(t)
& =   a_{cc} x_c(t)      + a_{cd} x_d(k*t_{sam}) + bc*u(t) \cr
x_d((k+1)*t_{sam})
& =   a_{dc} x_c(k t_{sam}) + a_{dd} x_d(k t_{sam}) + b_d u(k t_{sam}) \cr
y_c(t)
& =  c_{cc} x_c(t) + c_{cd} x_d(k t_{sam}) + d_c u(t) \cr
y_d(k t_{sam})
& =  c_{dc} x_c(k t_{sam}) + c_{dd} x_d(k t_{sam}) + d_d u(k t_{sam})
}$$
@end tex
@end iftex

@strong{Signal partitions}
@example
@group
| continuous      | discrete               |
----------------------------------------------------
states  | stname(1:n,:)   | stname((n+1):(n+nz),:) |
----------------------------------------------------
outputs | outname(cout,:) | outname(outlist,:)     |
----------------------------------------------------
@end group
@end example
where @math{cout} is the list of in 1:@code{rows}(@var{p})
that are not contained in outlist. (Discrete/continuous outputs
may be entered in any order desired by the user.)

@strong{Example}
@example
octave:1> a = [1 2 3; 4 5 6; 7 8 10];
octave:2> b = [0 0 ; 0 1 ; 1 0];
octave:3> c = eye (3);
octave:4> sys = ss (a, b, c, [], 0, 3, 0, ..
>                   @{"volts", "amps", "joules"@});
octave:5> sysout(sys);
Input(s)
1: u_1
2: u_2

Output(s):
1: y_1
2: y_2
3: y_3

state-space form:
3 continuous states, 0 discrete states
State(s):
1: volts
2: amps
3: joules

A matrix: 3 x 3
1   2   3
4   5   6
7   8  10
B matrix: 3 x 2
0  0
0  1
1  0
C matrix: 3 x 3
1  0  0
0  1  0
0  0  1
D matrix: 3 x 3
0  0
0  0
0  0
@end example
Notice that the @math{D} matrix is constructed  by default to the
correct dimensions.  Default input and output signals names were assigned
since none were given
@end deftypefn



@deftypefn {Function File} {} ss2sys (@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{outlist})
Create system structure from state-space data.   May be continuous,
discrete, or mixed (sampled data)

@strong{Inputs}
@table @var
@item a
@itemx b
@itemx c
@itemx d
usual state space matrices

default: @var{d} = zero matrix

@item   tsam
sampling rate.  Default: @math{tsam = 0} (continuous system)

@item n
@itemx nz
number of continuous, discrete states in the system

If @var{tsam} is 0, @math{n = @code{rows}(@var{a})}, @math{nz = 0}

If @var{tsam} is greater than zero, @math{n = 0},
@math{nz = @code{rows}(@var{a})}

see below for system partitioning

@item  stname
cell array of strings of state signal names

default (@var{stname}=[] on input): @code{x_n} for continuous states,
@code{xd_n} for discrete states

@item inname
cell array of strings of input signal names

default (@var{inname} = [] on input): @code{u_n}

@item outname
cell array of strings of input signal names

default (@var{outname} = [] on input): @code{y_n}

@item   outlist

list of indices of outputs y that are sampled

If @var{tsam} is 0, @math{outlist = []}

If @var{tsam} is greater than 0, @math{outlist = 1:@code{rows}(@var{c})}
@end table

Unlike states, discrete/continuous outputs may appear in any order

@code{sys2ss} returns a vector @var{yd} where
@var{yd}(@var{outlist}) = 1; all other entries of @var{yd} are 0

@strong{Outputs}
@var{outsys} = system data structure

@strong{System partitioning}

Suppose for simplicity that outlist specified
that the first several outputs were continuous and the remaining outputs
were discrete.  Then the system is partitioned as
@example
@group
x = [ xc ]  (n x 1)
[ xd ]  (nz x 1 discrete states)
a = [ acc acd ]  b = [ bc ]
[ adc add ]      [ bd ]
c = [ ccc ccd ]  d = [ dc ]
[ cdc cdd ]      [ dd ]

(cdc = c(outlist,1:n), etc.)
@end group
@end example
with dynamic equations:
@ifinfo
@math{d/dt xc(t)     = acc*xc(t)      + acd*xd(k*tsam) + bc*u(t)}

@math{xd((k+1)*tsam) = adc*xc(k*tsam) + add*xd(k*tsam) + bd*u(k*tsam)}

@math{yc(t)      = ccc*xc(t)      + ccd*xd(k*tsam) + dc*u(t)}

@math{yd(k*tsam) = cdc*xc(k*tsam) + cdd*xd(k*tsam) + dd*u(k*tsam)}
@end ifinfo
@iftex
@tex
$$\eqalign{
{d \over dt} x_c(t)
& =   a_{cc} x_c(t)      + a_{cd} x_d(k*t_{sam}) + bc*u(t) \cr
x_d((k+1)*t_{sam})
& =   a_{dc} x_c(k t_{sam}) + a_{dd} x_d(k t_{sam}) + b_d u(k t_{sam}) \cr
y_c(t)
& =  c_{cc} x_c(t) + c_{cd} x_d(k t_{sam}) + d_c u(t) \cr
y_d(k t_{sam})
& =  c_{dc} x_c(k t_{sam}) + c_{dd} x_d(k t_{sam}) + d_d u(k t_{sam})
}$$
@end tex
@end iftex

@strong{Signal partitions}
@example
@group
| continuous      | discrete               |
----------------------------------------------------
states  | stname(1:n,:)   | stname((n+1):(n+nz),:) |
----------------------------------------------------
outputs | outname(cout,:) | outname(outlist,:)     |
----------------------------------------------------
@end group
@end example
where @math{cout} is the list of in 1:@code{rows}(@var{p})
that are not contained in outlist. (Discrete/continuous outputs
may be entered in any order desired by the user.)

@strong{Example}
@example
octave:1> a = [1 2 3; 4 5 6; 7 8 10];
octave:2> b = [0 0 ; 0 1 ; 1 0];
octave:3> c = eye (3);
octave:4> sys = ss (a, b, c, [], 0, 3, 0,
>                   @{"volts", "amps", "joules"@});
octave:5> sysout(sys);
Input(s)
1: u_1
2: u_2

Output(s):
1: y_1
2: y_2
3: y_3

state-space form:
3 continuous states, 0 discrete states
State(s):
1: volts
2: amps
3: joules

A matrix: 3 x 3
1   2   3
4   5   6
7   8  10
B matrix: 3 x 2
0  0
0  1
1  0
C matrix: 3 x 3
1  0  0
0  1  0
0  0  1
D matrix: 3 x 3
0  0
0  0
0  0
@end example
Notice that the @math{D} matrix is constructed  by default to the
correct dimensions.  Default input and output signals names were assigned
since none were given
@end deftypefn



@deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{yd}] =} sys2ss (@var{sys})
Extract state space representation from system data structure

@strong{Input}
@table @var
@item sys
System data structure
@end table

@strong{Outputs}
@table @var
@item a
@itemx b
@itemx c
@itemx d
State space matrices for @var{sys}

@item tsam
Sampling time of @var{sys} (0 if continuous)

@item n
@itemx nz
Number of continuous, discrete states (discrete states come
last in state vector @var{x})

@item stname
@itemx inname
@itemx outname
Signal names (lists of strings);  names of states,
inputs, and outputs, respectively

@item yd
Binary vector; @var{yd}(@var{ii}) is 1 if output @var{y}(@var{ii})
is discrete (sampled); otherwise  @var{yd}(@var{ii}) is 0

@end table
A warning massage is printed if the system is a mixed
continuous and discrete system

@strong{Example}
@example
octave:1> sys=tf2sys([1 2],[3 4 5]);
octave:2> [a,b,c,d] = sys2ss(sys)
a =
0.00000   1.00000
-1.66667  -1.33333
b =
0
1
c = 0.66667  0.33333
d = 0
@end example
@end deftypefn



@node tf2sys
@section Transfer function system interface functions

@deftypefn {Function File} {} tf (@var{num}, @var{den}, @var{tsam}, @var{inname}, @var{outname})
build system data structure from transfer function format data

@strong{Inputs}
@table @var
@item  num
@itemx den
coefficients of numerator/denominator polynomials
@item tsam
sampling interval. default: 0 (continuous time)
@item inname
@itemx outname
input/output signal names; may be a string or cell array with a single string
entry
@end table

@strong{Outputs}
@var{sys} = system data structure

@strong{Example}
@example
octave:1> sys=tf([2 1],[1 2 1],0.1);
octave:2> sysout(sys)
Input(s)
1: u_1
Output(s):
1: y_1 (discrete)
Sampling interval: 0.1
transfer function form:
2*z^1 + 1
-----------------
1*z^2 + 2*z^1 + 1
@end example
@end deftypefn



@deftypefn {Function File} {} tf2sys (@var{num}, @var{den}, @var{tsam}, @var{inname}, @var{outname})
Build system data structure from transfer function format data

@strong{Inputs}
@table @var
@item  num
@itemx den
Coefficients of numerator/denominator polynomials
@item tsam
Sampling interval; default: 0 (continuous time)
@item inname
@itemx outname
Input/output signal names; may be a string or cell array with a single string
entry
@end table

@strong{Output}
@table @var
@item sys
System data structure
@end table

@strong{Example}
@example
octave:1> sys=tf2sys([2 1],[1 2 1],0.1);
octave:2> sysout(sys)
Input(s)
1: u_1
Output(s):
1: y_1 (discrete)
Sampling interval: 0.1
transfer function form:
2*z^1 + 1
-----------------
1*z^2 + 2*z^1 + 1
@end example
@end deftypefn



@deftypefn {Function File} {[@var{num}, @var{den}, @var{tsam}, @var{inname}, @var{outname}] =} sys2tf (@var{sys})
Extract transfer function data from a system data structure

See @command{tf} for parameter descriptions

@strong{Example}
@example
octave:1> sys=ss([1 -2; -1.1,-2.1],[0;1],[1 1]);
octave:2> [num,den] = sys2tf(sys)
num = 1.0000  -3.0000
den = 1.0000   1.1000  -4.3000
@end example
@end deftypefn



@node zp2sys
@section Zero-pole system interface functions

@deftypefn {Function File} {} zp (@var{zer}, @var{pol}, @var{k}, @var{tsam}, @var{inname}, @var{outname})
Create system data structure from zero-pole data

@strong{Inputs}
@table @var
@item   zer
vector of system zeros
@item   pol
vector of system poles
@item   k
scalar leading coefficient
@item   tsam
sampling period. default: 0 (continuous system)
@item   inname
@itemx  outname
input/output signal names (lists of strings)
@end table

@strong{Outputs}
sys: system data structure

@strong{Example}
@example
octave:1> sys=zp([1 -1],[-2 -2 0],1);
octave:2> sysout(sys)
Input(s)
1: u_1
Output(s):
1: y_1
zero-pole form:
1 (s - 1) (s + 1)
-----------------
s (s + 2) (s + 2)
@end example
@end deftypefn



@deftypefn {Function File} {} zp2sys (@var{zer}, @var{pol}, @var{k}, @var{tsam}, @var{inname}, @var{outname})
Create system data structure from zero-pole data

@strong{Inputs}
@table @var
@item   zer
Vector of system zeros
@item   pol
Vector of system poles
@item   k
Scalar leading coefficient
@item   tsam
Sampling period; default: 0 (continuous system)
@item   inname
@itemx  outname
Input/output signal names (lists of strings)
@end table

@strong{Output}
@table @var
@item sys
System data structure
@end table

@strong{Example}
@example
octave:1> sys=zp2sys([1 -1],[-2 -2 0],1);
octave:2> sysout(sys)
Input(s)
1: u_1
Output(s):
1: y_1
zero-pole form:
1 (s - 1) (s + 1)
-----------------
s (s + 2) (s + 2)
@end example
@end deftypefn



@deftypefn {Function File} {[@var{zer}, @var{pol}, @var{k}, @var{tsam}, @var{inname}, @var{outname}] =} sys2zp (@var{sys})
Extract zero/pole/leading coefficient information from a system data
structure

See @command{zp} for parameter descriptions

@strong{Example}
@example
octave:1> sys=ss([1 -2; -1.1,-2.1],[0;1],[1 1]);
octave:2> [zer,pol,k] = sys2zp(sys)
zer = 3.0000
pol =
-2.6953
1.5953
k = 1
@end example
@end deftypefn



@node structaccess
@section Data structure access functions

@deftypefn {Function File} {} syschnames (@var{sys}, @var{opt}, @var{list}, @var{names})
Superseded by @command{syssetsignals}
@end deftypefn



@deftypefn {Function File} {} syschtsam (@var{sys}, @var{tsam})
This function changes the sampling time (tsam) of the system.  Exits with
an error if sys is purely continuous time
@end deftypefn



@deftypefn {Function File} {[@var{n}, @var{nz}, @var{m}, @var{p}, @var{yd}] =} sysdimensions (@var{sys}, @var{opt})
return the number of states, inputs, and/or outputs in the system
@var{sys}

@strong{Inputs}
@table @var
@item sys
system data structure

@item opt
String indicating which dimensions are desired.  Values:
@table @code
@item "all"
(default) return all parameters as specified under Outputs below

@item "cst"
return @var{n}= number of continuous states

@item "dst"
return @var{n}= number of discrete states

@item "in"
return @var{n}= number of inputs

@item "out"
return @var{n}= number of outputs
@end table
@end table

@strong{Outputs}
@table @var
@item  n
number of continuous states (or individual requested dimension as specified
by @var{opt})
@item  nz
number of discrete states
@item  m
number of system inputs
@item  p
number of system outputs
@item  yd
binary vector; @var{yd}(@var{ii}) is nonzero if output @var{ii} is
discrete
@math{yd(ii) = 0} if output @var{ii} is continuous
@end table
See also: sysgetsignals, sysgettsam
@end deftypefn



@deftypefn {Function File} {[@var{stname}, @var{inname}, @var{outname}, @var{yd}] =} sysgetsignals (@var{sys})
@deftypefnx {Function File} {@var{siglist} =} sysgetsignals (@var{sys}, @var{sigid})
@deftypefnx {Function File} {@var{signame} =} sysgetsignals (@var{sys}, @var{sigid}, @var{signum}, @var{strflg})
Get signal names from a system

@strong{Inputs}
@table @var
@item sys
system data structure for the state space system

@item sigid
signal id.  String.  Must be one of
@table @code
@item "in"
input signals
@item "out"
output signals
@item "st"
stage signals
@item "yd"
value of logical vector @var{yd}
@end table

@item signum
index(indices) or name(s) or signals; see @code{sysidx}

@item strflg
flag to return a string instead of a cell array;  Values:
@table @code
@item 0
(default) return a cell array (even if signum specifies an individual signal)

@item 1
return a string.  Exits with an error if signum does not specify an
individual signal
@end table

@end table

@strong{Outputs}
@table @bullet
@item If @var{sigid} is not specified:
@table @var
@item stname
@itemx inname
@itemx outname
signal names (cell array of strings);  names of states,
inputs, and outputs, respectively
@item yd
binary vector; @var{yd}(@var{ii}) is nonzero if output @var{ii} is
discrete
@end table

@item If @var{sigid} is specified but @var{signum} is not specified:
@table @code
@item sigid="in"
@var{siglist} is set to the cell array of input names

@item sigid="out"
@var{siglist} is set to the cell array of output names

@item sigid="st"
@var{siglist} is set to the cell array of state names

stage signals
@item sigid="yd"
@var{siglist} is set to logical vector indicating discrete outputs;
@var{siglist}(@var{ii}) = 0 indicates that output @var{ii} is continuous
(unsampled), otherwise it is discrete

@end table

@item If the first three input arguments are specified:
@var{signame} is a cell array of the specified signal names (@var{sigid} is
@code{"in"}, @code{"out"}, or @code{"st"}), or else the logical flag
indicating whether output(s) @var{signum} is(are) discrete (@var{sigval}=1)
or continuous (@var{sigval}=0)
@end table

@strong{Examples} (From @code{sysrepdemo})
@example
octave> sys=ss(rand(4),rand(4,2),rand(3,4));
octave># get all signal names
octave> [Ast,Ain,Aout,Ayd] = sysgetsignals(sys)
Ast =
(
[1] = x_1
[2] = x_2
[3] = x_3
[4] = x_4
)
Ain =
(
[1] = u_1
[2] = u_2
)
Aout =
(
[1] = y_1
[2] = y_2
[3] = y_3
)
Ayd =

0  0  0
octave> # get only input signal names:
octave> Ain = sysgetsignals(sys,"in")
Ain =
(
[1] = u_1
[2] = u_2
)
octave> # get name of output 2 (in cell array):
octave> Aout = sysgetsignals(sys,"out",2)
Aout =
(
[1] = y_2
)
octave> # get name of output 2 (as string):
octave> Aout = sysgetsignals(sys,"out",2,1)
Aout = y_2
@end example
@end deftypefn



@deftypefn {Function File} {} sysgettype (@var{sys})
return the initial system type of the system

@strong{Input}
@table @var
@item sys
System data structure
@end table

@strong{Output}
@table @var
@item systype
String indicating how the structure was initially
constructed. Values: @code{"ss"}, @code{"zp"}, or @code{"tf"}
@end table

@acronym{FIR} initialized systems return @code{systype="tf"}
@end deftypefn



@deftypefn {Function File} {} syssetsignals (@var{sys}, @var{opt}, @var{names}, @var{sig_idx})
change the names of selected inputs, outputs and states

@strong{Inputs}
@table @var
@item sys
System data structure

@item opt
Change default name (output)

@table @code
@item "out"
Change selected output names
@item "in"
Change selected input names
@item "st"
Change selected state names
@item "yd"
Change selected outputs from discrete to continuous or
from continuous to discrete
@end table

@item names
@table @code
@item opt = "out", "in", "st"
string or string array containing desired signal names or values
@item opt = "yd"
To desired output continuous/discrete flag
Set name to 0 for continuous, or 1 for discrete
@end table
@item sig_idx
indices or names of outputs, yd, inputs, or
states whose respective names/values should be changed

Default: replace entire cell array of names/entire yd vector
@end table

@strong{Outputs}
@table @var
@item retsys
@var{sys} with appropriate signal names changed
(or @var{yd} values, where appropriate)
@end table

@strong{Example}
@example
octave:1> sys=ss ([1 2; 3 4],[5;6],[7 8]);
octave:2> sys = syssetsignals (sys, "st",
>                              str2mat("Posx","Velx"));
octave:3> sysout(sys)
Input(s)
1: u_1
Output(s):
1: y_1
state-space form:
2 continuous states, 0 discrete states
State(s):
1: Posx
2: Velx
A matrix: 2 x 2
1  2
3  4
B matrix: 2 x 1
5
6
C matrix: 1 x 2
7  8
D matrix: 1 x 1
0
@end example
@end deftypefn



@deftypefn {Function File} {} sysupdate (@var{sys}, @var{opt})
Update the internal representation of a system

@strong{Inputs}
@table @var
@item sys:
system data structure
@item opt
string:
@table @code
@item "tf"
update transfer function form
@item "zp"
update zero-pole form
@item "ss"
update state space form
@item "all"
all of the above
@end table
@end table

@strong{Outputs}
@table @var
@item retsys
Contains union of data in sys and requested data
If requested data in @var{sys} is already up to date then @var{retsys}=@var{sys}
@end table

Conversion to @command{tf} or @command{zp} exits with an error if the system is
mixed continuous/digital
See also: tf, ss, zp, sysout, sys2ss, sys2tf, sys2zp
@end deftypefn



@deftypefn {Function File} {[@var{systype}, @var{nout}, @var{nin}, @var{ncstates}, @var{ndstates}] =} minfo (@var{inmat})
Determines the type of system matrix.  @var{inmat} can be a varying,
a system, a constant, and an empty matrix

@strong{Outputs}
@table @var
@item systype
Can be one of: varying, system, constant, and empty
@item nout
The number of outputs of the system
@item nin
The number of inputs of the system
@item ncstates
The number of continuous states of the system
@item ndstates
The number of discrete states of the system
@end table
@end deftypefn



@deftypefn {Function File} {} sysgettsam (@var{sys})
Return the sampling time of the system @var{sys}
@end deftypefn



@node sysdisp
@chapter System display functions

@deftypefn {Function File} {} sysout (@var{sys}, @var{opt})
print out a system data structure in desired format
@table @var
@item  sys
system data structure
@item  opt
Display option
@table @code
@item []
primary system form (default)
@item      "ss"
state space form
@item      "tf"
transfer function form
@item      "zp"
zero-pole form
@item      "all"
all of the above
@end table
@end table
@end deftypefn



@deftypefn {Function File} {} tfout (@var{num}, @var{denom}, @var{x})
Print formatted transfer function @math{n(s)/d(s)} to the screen
@var{x} defaults to the string @code{"s"}
See also: polyval, polyvalm, poly, roots, conv, deconv, residue, filter, polyderiv, polyinteg, polyout
@end deftypefn



@deftypefn {Function File} {} zpout (@var{zer}, @var{pol}, @var{k}, @var{x})
print formatted zero-pole form to the screen
@var{x} defaults to the string @code{"s"}
See also: polyval, polyvalm, poly, roots, conv, deconv, residue, filter, polyderiv, polyinteg, polyout
@end deftypefn



@node blockdiag
@chapter Block Diagram Manipulations

@xref{systime}.

Unless otherwise noted, all parameters (input,output) are
system data structures.

@deftypefn {Function File} {} bddemo (@var{inputs})
Octave Controls toolbox demo: Block Diagram Manipulations demo
@end deftypefn



@deftypefn {Function File} {} buildssic (@var{clst}, @var{ulst}, @var{olst}, @var{ilst}, @var{s1}, @var{s2}, @var{s3}, @var{s4}, @var{s5}, @var{s6}, @var{s7}, @var{s8})

Form an arbitrary complex (open or closed loop) system in
state-space form from several systems. @command{buildssic} can
easily (despite its cryptic syntax) integrate transfer functions
from a complex block diagram into a single system with one call
This function is especially useful for building open loop
interconnections for
@iftex
@tex
$ { \cal H }_\infty $ and $ { \cal H }_2 $
@end tex
@end iftex
@ifinfo
H-infinity and H-2
@end ifinfo
designs or for closing loops with these controllers

Although this function is general purpose, the use of @command{sysgroup}
@command{sysmult}, @command{sysconnect} and the like is recommended for
standard operations since they can handle mixed discrete and continuous
systems and also the names of inputs, outputs, and states

The parameters consist of 4 lists that describe the connections
outputs and inputs and up to 8 systems @var{s1}--@var{s8}
Format of the lists:
@table @var
@item      clst
connection list, describes the input signal of
each system. The maximum number of rows of Clst is
equal to the sum of all inputs of s1-s8

Example:
@code{[1 2 -1; 2 1 0]} means that:  new input 1 is old input 1
+ output 2 - output 1, and new input 2 is old input 2
+ output 1. The order of rows is arbitrary

@item ulst
if not empty the old inputs in vector @var{ulst} will
be appended to the outputs. You need this if you
want to ``pull out'' the input of a system. Elements
are input numbers of @var{s1}--@var{s8}

@item olst
output list, specifies the outputs of the resulting
systems. Elements are output numbers of @var{s1}--@var{s8}
The numbers are allowed to be negative and may
appear in any order. An empty matrix means
all outputs

@item ilst
input list, specifies the inputs of the resulting
systems. Elements are input numbers of @var{s1}--@var{s8}
The numbers are allowed to be negative and may
appear in any order. An empty matrix means
all inputs
@end table

Example:  Very simple closed loop system
@example
@group
w        e  +-----+   u  +-----+
--->o--*-->|  K  |--*-->|  G  |--*---> y
^  |   +-----+  |   +-----+  |
- |  |            |            |
|  |            +----------------> u
|  |                         |
|  +-------------------------|---> e
|                            |
+----------------------------+
@end group
@end example

The closed loop system @var{GW} can be obtained by
@example
GW = buildssic([1 2; 2 -1], 2, [1 2 3], 2, G, K);
@end example
@table @var
@item clst
1st row: connect input 1 (@var{G}) with output 2 (@var{K})

2nd row: connect input 2 (@var{K}) with negative output 1 (@var{G})
@item ulst
Append input of 2 (@var{K}) to the number of outputs
@item olst
Outputs are output of 1 (@var{G}), 2 (@var{K}) and
appended output 3 (from @var{ulst})
@item ilst
The only input is 2 (@var{K})
@end table

Here is a real example:
@example
@group
+----+
-------------------->| W1 |---> v1
z   |                    +----+
----|-------------+
|             |
|    +---+    v      +----+
*--->| G |--->O--*-->| W2 |---> v2
|    +---+       |   +----+
|                |
|                v
u                  y
@end group
@end example
@iftex
@tex
$$ { \rm min } \Vert GW_{vz} \Vert _\infty $$
@end tex
@end iftex
@ifinfo
@example
min || GW   ||
vz   infty
@end example
@end ifinfo

The closed loop system @var{GW}
@iftex
@tex
from $ [z, u]^T $ to $ [v_1, v_2, y]^T $
@end tex
@end iftex
@ifinfo
from [z, u]' to [v1, v2, y]'
@end ifinfo
can be obtained by (all @acronym{SISO} systems):
@example
GW = buildssic([1, 4; 2, 4; 3, 1], 3, [2, 3, 5],
[3, 4], G, W1, W2, One);
@end example
where ``One'' is a unity gain (auxiliary) function with order 0
(e.g. @code{One = ugain(1);})
@end deftypefn



@deftypefn {Function File} {@var{sys} =} jet707 ()
Creates a linearized state-space model of a Boeing 707-321 aircraft
at @var{v}=80 m/s
@iftex
@tex
($M = 0.26$, $G_{a0} = -3^{\circ}$, ${\alpha}_0 = 4^{\circ}$, ${\kappa}= 50^{\circ}$)
@end tex
@end iftex
@ifinfo
(@var{M} = 0.26, @var{Ga0} = -3 deg, @var{alpha0} = 4 deg, @var{kappa} = 50 deg)
@end ifinfo

System inputs: (1) thrust and (2) elevator angle

System outputs:  (1) airspeed and (2) pitch angle

@strong{Reference}: R. Brockhaus: @cite{Flugregelung} (Flight
Control), Springer, 1994
See also: ord2
@end deftypefn



@deftypefn {Function File} {} ord2 (@var{nfreq}, @var{damp}, @var{gain})
Creates a continuous 2nd order system with parameters:

@strong{Inputs}
@table @var
@item nfreq
natural frequency [Hz]. (not in rad/s)
@item damp
damping coefficient
@item gain
dc-gain
This is steady state value only for damp > 0
gain is assumed to be 1.0 if omitted
@end table

@strong{Output}
@table @var
@item outsys
system data structure has representation with
@ifinfo
@math{w = 2 * pi * nfreq}:
@end ifinfo
@iftex
@tex
$ w = 2  \pi  f $:
@end tex
@end iftex
@example
@group
/                                        \
| / -2w*damp -w \  / w \                 |
G = | |             |, |   |, [ 0  gain ], 0 |
| \   w       0 /  \ 0 /                 |
\                                        /
@end group
@end example
@end table
@strong{See also} @command{jet707} (@acronym{MIMO} example, Boeing 707-321
aircraft model)
@end deftypefn



@deftypefn {Function File} {}  sysadd (@var{gsys}, @var{hsys})
returns @var{sys} = @var{gsys} + @var{hsys}
@itemize @bullet
@item Exits with
an error if @var{gsys} and @var{hsys} are not compatibly dimensioned
@item Prints a warning message is system states have identical names;
duplicate names are given a suffix to make them unique
@item @var{sys} input/output names are taken from @var{gsys}
@end itemize
@example
@group
________
----|  gsys  |---
u   |    ----------  +|
-----                (_)----> y
|     ________   +|
----|  hsys  |---
--------
@end group
@end example
@end deftypefn



@deftypefn {Function File} {@var{sys} =} sysappend (@var{syst}, @var{b}, @var{c}, @var{d}, @var{outname}, @var{inname}, @var{yd})
appends new inputs and/or outputs to a system

@strong{Inputs}
@table @var
@item syst
system data structure

@item b
matrix to be appended to sys "B" matrix (empty if none)

@item c
matrix to be appended to sys "C" matrix (empty if none)

@item d
revised sys d matrix (can be passed as [] if the revised d is all zeros)

@item outname
list of names for new outputs

@item inname
list of names for new inputs

@item yd
binary vector; @math{yd(ii)=0} indicates a continuous output;
@math{yd(ii)=1} indicates a discrete output
@end table

@strong{Outputs}
@table @var
@item sys
@example
@group
sys.b := [syst.b , b]
sys.c := [syst.c  ]
[ c     ]
sys.d := [syst.d | D12 ]
[ D21   | D22 ]
@end group
@end example
where @math{D12}, @math{D21}, and @math{D22} are the appropriate dimensioned
blocks of the input parameter @var{d}
@itemize @bullet
@item The leading block @math{D11} of @var{d} is ignored
@item If @var{inname} and @var{outname} are not given as arguments,
the new inputs and outputs are be assigned default names
@item @var{yd} is a binary vector of length rows(c) that indicates
continuous/sampled outputs.  Default value for @var{yd} is:
@itemize @minus
@item @var{sys} is continuous or mixed
@var{yd} = @code{zeros(1,rows(c))}

@item @var{sys} is discrete
@var{yd} = @code{ones(1,rows(c))}
@end itemize
@end itemize
@end table
@end deftypefn



@deftypefn {Function File} {@var{clsys} =} sysconnect (@var{sys}, @var{out_idx}, @var{in_idx}, @var{order}, @var{tol})
Close the loop from specified outputs to respective specified inputs

@strong{Inputs}
@table @var
@item   sys
System data structure
@item   out_idx
@itemx  in_idx
Names or indices of signals to connect (see @code{sysidx})
The output specified by @math{out_idx(ii)} is connected to the input
specified by @math{in_idx(ii)}
@item   order
logical flag (default = 0)
@table @code
@item        0
Leave inputs and outputs in their original order
@item        1
Permute inputs and outputs to the order shown in the diagram below
@end table
@item     tol
Tolerance for singularities in algebraic loops, default: 200@code{eps}
@end table

@strong{Outputs}
@table @var
@item clsys
Resulting closed loop system
@end table

@strong{Method}

@code{sysconnect} internally permutes selected inputs, outputs as shown
below, closes the loop, and then permutes inputs and outputs back to their
original order
@example
@group
--------------------
u_1       ----->|                  |----> y_1
|        sys       |
old u_2 |                  |
u_2* ---->(+)--->|                  |----->y_2
(in_idx)   ^     --------------------    | (out_idx)
|                             |
-------------------------------
@end group
@end example
The input that has the summing junction added to it has an * added to
the end  of the input name
@end deftypefn



@deftypefn {Function File} {[@var{csys}, @var{acd}, @var{ccd}] =} syscont (@var{sys})
Extract the purely continuous subsystem of an input system

@strong{Input}
@table @var
@item sys
system data structure
@end table

@strong{Outputs}
@table @var
@item csys
is the purely continuous input/output connections of @var{sys}
@item acd
@itemx ccd
connections from discrete states to continuous states,
discrete states to continuous outputs, respectively

If no continuous path exists, @var{csys} will be empty
@end table
@end deftypefn



@deftypefn {Function File} {[@var{dsys}, @var{adc}, @var{cdc}] =} sysdisc (@var{sys})

@strong{Input}
@table @var
@item sys
System data structure
@end table

@strong{Outputs}
@table @var
@item dsys
Purely discrete portion of sys (returned empty if there is
no purely discrete path from inputs to outputs)
@item    adc
@itemx   cdc
Connections from continuous states to discrete states and discrete
outputs, respectively
@end table
@end deftypefn



@deftypefn {Function File} {@var{retsys} =} sysdup (@var{asys}, @var{out_idx}, @var{in_idx})
Duplicate specified input/output connections of a system

@strong{Inputs}
@table @var
@item asys
system data structure
@item out_idx
@itemx in_idx
indices or names of desired signals (see @code{sigidx})
duplicates are made of @code{y(out_idx(ii))} and @code{u(in_idx(ii))}
@end table

@strong{Output}
@table @var
@item retsys
Resulting closed loop system:
duplicated i/o names are appended with a @code{"+"} suffix
@end table

@strong{Method}

@code{sysdup} creates copies of selected inputs and outputs as
shown below.  @var{u1}, @var{y1} is the set of original inputs/outputs, and
@var{u2}, @var{y2} is the set of duplicated inputs/outputs in the order
specified in @var{in_idx}, @var{out_idx}, respectively
@example
@group
____________________
u1  ----->|                  |----> y1
|       asys       |
u2 ------>|                  |----->y2
(in_idx)  -------------------- (out_idx)
@end group
@end example
@end deftypefn



@deftypefn {Function File} {@var{sys} =} sysgroup (@var{asys}, @var{bsys})
Combines two systems into a single system

@strong{Inputs}
@table @var
@item asys
@itemx bsys
System data structures
@end table

@strong{Output}
@table @var
@item sys
@math{sys = @r{block diag}(asys,bsys)}
@end table
@example
@group
__________________
|    ________    |
u1 ----->|--> | asys |--->|----> y1
|    --------    |
|    ________    |
u2 ----->|--> | bsys |--->|----> y2
|    --------    |
------------------
Ksys
@end group
@end example
The function also rearranges the internal state-space realization of @var{sys}
so that the continuous states come first and the discrete states come last
If there are duplicate names, the second name has a unique suffix appended
on to the end of the name
@end deftypefn



@deftypefn {Function File} {@var{sys} =} sysmult (@var{Asys}, @var{Bsys})
Compute @math{sys = Asys*Bsys} (series connection):
@example
@group
u   ----------     ----------
--->|  Bsys  |---->|  Asys  |--->
----------     ----------
@end group
@end example
A warning occurs if there is direct feed-through from an input
or a continuous state of @var{Bsys}, through a discrete output
of @var{Bsys}, to a continuous state or output in @var{Asys}
(system data structure does not recognize discrete inputs)
@end deftypefn



@deftypefn {Function File} {@var{retsys} =} sysprune (@var{asys}, @var{out_idx}, @var{in_idx})
Extract specified inputs/outputs from a system

@strong{Inputs}
@table @var
@item asys
system data structure
@item out_idx
@itemx in_idx
Indices or signal names of the outputs and inputs to be kept in the returned
system; remaining connections are ``pruned'' off
May select as [] (empty matrix) to specify all outputs/inputs

@example
retsys = sysprune (Asys, [1:3,4], "u_1");
retsys = sysprune (Asys, @{"tx", "ty", "tz"@}, 4);
@end example

@end table

@strong{Output}
@table @var
@item retsys
Resulting system
@end table
@example
@group
____________________
u1 ------->|                  |----> y1
(in_idx)  |       Asys       | (out_idx)
u2 ------->|                  |----| y2
(deleted)-------------------- (deleted)
@end group
@end example
@end deftypefn



@deftypefn {Function File} {@var{pv} =} sysreorder (@var{vlen}, @var{list})

@strong{Inputs}
@table @var
@item vlen
Vector length
@item list
A subset of @code{[1:vlen]}
@end table

@strong{Output}
@table @var
@item pv
A permutation vector to order elements of @code{[1:vlen]} in
@code{list} to the end of a vector
@end table

Used internally by @code{sysconnect} to permute vector elements to their
desired locations
@end deftypefn



@deftypefn {Function File} {@var{retsys} =} sysscale (@var{sys}, @var{outscale}, @var{inscale}, @var{outname}, @var{inname})
scale inputs/outputs of a system

@strong{Inputs}
@table @var
@item sys
Structured system
@item outscale
@itemx inscale
Constant matrices of appropriate dimension
@item outname
@itemx inname
Lists of strings with the names of respectively outputs and inputs
@end table

@strong{Output}
@table @var
@item retsys
resulting open loop system:
@smallexample
-----------    -------    -----------
u --->| inscale |--->| sys |--->| outscale |---> y
-----------    -------    -----------
@end smallexample
@end table
If the input names and output names (each a list of strings)
are not given and the scaling matrices
are not square, then default names will be given to the inputs and/or
outputs

A warning message is printed if outscale attempts to add continuous
system outputs to discrete system outputs; otherwise @var{yd} is
set appropriately in the returned value of @var{sys}
@end deftypefn



@deftypefn {Function File} {@var{sys} =} syssub (@var{Gsys}, @var{Hsys})
Return @math{sys = Gsys - Hsys}

@strong{Method}

@var{Gsys} and @var{Hsys} are connected in parallel
The input vector is connected to both systems; the outputs are
subtracted.  Returned system names are those of @var{Gsys}
@example
@group
+--------+
+--->|  Gsys  |---+
|    +--------+   |
|                +|
u --+                (_)--> y
|                -|
|    +--------+   |
+--->|  Hsys  |---+
+--------+
@end group
@end example
@end deftypefn



@deftypefn {Function File} {} ugain (@var{n})
Creates a system with unity gain, no states
This trivial system is sometimes needed to create arbitrary
complex systems from simple systems with @command{buildssic}
Watch out if you are forming sampled systems since @command{ugain}
does not contain a sampling period
See also: hinfdemo, jet707
@end deftypefn



@deftypefn {Function File} {@var{W} =} wgt1o (@var{vl}, @var{vh}, @var{fc})
State space description of a first order weighting function

Weighting function are needed by the
@iftex
@tex
$ { \cal H }_2 / { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-2/H-infinity
@end ifinfo
design procedure
These functions are part of the augmented plant @var{P}
(see @command{hinfdemo} for an application example)

@strong{Inputs}
@table @var
@item vl
Gain at low frequencies
@item vh
Gain at high frequencies
@item fc
Corner frequency (in Hz, @strong{not} in rad/sec)
@end table

@strong{Output}
@table @var
@item W
Weighting function, given in form of a system data structure
@end table
@end deftypefn



@deftypefn {Function File} {@var{ksys} =} parallel (@var{asys}, @var{bsys})
Forms the parallel connection of two systems

@example
@group
--------------------
|      --------    |
u  ----->|----> | asys |--->|----> y1
|    |      --------    |
|    |      --------    |
|--->|----> | bsys |--->|----> y2
|      --------    |
--------------------
ksys
@end group
@end example
@end deftypefn



@deftypefn {Function File} {[@var{retsys}, @var{nc}, @var{no}] =} sysmin (@var{sys}, @var{flg})
Returns a minimal (or reduced order) system

@strong{Inputs}
@table @var
@item sys
System data structure
@item flg
When equal to 0 (default value), returns minimal system,
in which state names are lost; when equal to 1, returns system
with physical states removed that are either uncontrollable or
unobservable (cannot reduce further without discarding physical
meaning of states)
@end table
@strong{Outputs}
@table @var
@item retsys
Returned system
@item nc
Number of controllable states in the returned system
@item no
Number of observable states in the returned system
@item cflg
@code{is_controllable(retsys)}
@item oflg
@code{is_observable(retsys)}
@end table
@end deftypefn



@node numerical
@chapter Numerical Functions

@deftypefn {Function File} {@var{x} =} are (@var{a}, @var{b}, @var{c}, @var{opt})
Solve the Algebraic Riccati Equation
@iftex
@tex
$$
A^TX + XA - XBX + C = 0
$$
@end tex
@end iftex
@ifinfo
@example
a' * x + x * a - x * b * x + c = 0
@end example
@end ifinfo

@strong{Inputs}
@noindent
for identically dimensioned square matrices
@table @var
@item a
@var{n} by @var{n} matrix;
@item b
@var{n} by @var{n} matrix or @var{n} by @var{m} matrix; in the latter case
@var{b} is replaced by @math{b:=b*b'};
@item c
@var{n} by @var{n} matrix or @var{p} by @var{m} matrix; in the latter case
@var{c} is replaced by @math{c:=c'*c};
@item opt
(optional argument; default = @code{"B"}):
String option passed to @code{balance} prior to ordered Schur decomposition
@end table

@strong{Output}
@table @var
@item x
solution of the @acronym{ARE}
@end table

@strong{Method}
Laub's Schur method (@acronym{IEEE} Transactions on
Automatic Control, 1979) is applied to the appropriate Hamiltonian
matrix
See also: balance, dare
@end deftypefn



@deftypefn {Function File} {@var{x} =} dare (@var{a}, @var{b}, @var{q}, @var{r}, @var{opt})

Return the solution, @var{x} of the discrete-time algebraic Riccati
equation
@iftex
@tex
$$
A^TXA - X + A^TXB  (R + B^TXB)^{-1} B^TXA + Q = 0
$$
@end tex
@end iftex
@ifinfo
@example
a' x a - x + a' x b (r + b' x b)^(-1) b' x a + q = 0
@end example
@end ifinfo
@noindent

@strong{Inputs}
@table @var
@item a
@var{n} by @var{n} matrix;

@item b
@var{n} by @var{m} matrix;

@item q
@var{n} by @var{n} matrix, symmetric positive semidefinite, or a @var{p} by @var{n} matrix,
In the latter case @math{q:=q'*q} is used;

@item r
@var{m} by @var{m}, symmetric positive definite (invertible);

@item opt
(optional argument; default = @code{"B"}):
String option passed to @code{balance} prior to ordered @var{QZ} decomposition
@end table

@strong{Output}
@table @var
@item x
solution of @acronym{DARE}
@end table

@strong{Method}
Generalized eigenvalue approach (Van Dooren; @acronym{SIAM} J
Sci. Stat. Comput., Vol 2) applied  to the appropriate symplectic pencil

See also: Ran and Rodman, @cite{Stable Hermitian Solutions of Discrete
Algebraic Riccati Equations}, Mathematics of Control, Signals and
Systems, Vol 5, no 2 (1992), pp 165--194
See also: balance, are
@end deftypefn



@deftypefn {Function File} {[@var{tvals}, @var{plist}] =} dre (@var{sys}, @var{q}, @var{r}, @var{qf}, @var{t0}, @var{tf}, @var{ptol}, @var{maxits})
Solve the differential Riccati equation
@ifinfo
@example
-d P/dt = A'P + P A - P B inv(R) B' P + Q
P(tf) = Qf
@end example
@end ifinfo
@iftex
@tex
$$ -{dP \over dt} = A^T P+PA-PBR^{-1}B^T P+Q $$
$$ P(t_f) = Q_f $$
@end tex
@end iftex
for the @acronym{LTI} system sys.  Solution of
standard @acronym{LTI} state feedback optimization
@ifinfo
@example
min int(t0, tf) ( x' Q x + u' R u ) dt + x(tf)' Qf x(tf)
@end example
@end ifinfo
@iftex
@tex
$$ \min \int_{t_0}^{t_f} x^T Q x + u^T R u dt + x(t_f)^T Q_f x(t_f) $$
@end tex
@end iftex
optimal input is
@ifinfo
@example
u = - inv(R) B' P(t) x
@end example
@end ifinfo
@iftex
@tex
$$ u = - R^{-1} B^T P(t) x $$
@end tex
@end iftex
@strong{Inputs}
@table @var
@item sys
continuous time system data structure
@item q
state integral penalty
@item r
input integral penalty
@item qf
state terminal penalty
@item t0
@itemx tf
limits on the integral
@item ptol
tolerance (used to select time samples; see below); default = 0.1
@item maxits
number of refinement iterations (default=10)
@end table
@strong{Outputs}
@table @var
@item tvals
time values at which @var{p}(@var{t}) is computed
@item plist
list values of @var{p}(@var{t}); @var{plist} @{ @var{i} @}
is @var{p}(@var{tvals}(@var{i}))
@end table
@var{tvals} is selected so that:
@iftex
@tex
$$ \Vert plist_{i} - plist_{i-1} \Vert < ptol $$
@end tex
@end iftex
@ifinfo
@example
|| Plist@{i@} - Plist@{i-1@} || < Ptol
@end example
@end ifinfo
for every @var{i} between 2 and length(@var{tvals})
@end deftypefn



@deftypefn {Function File} {} dgram (@var{a}, @var{b})
Return controllability gramian of discrete time system
@iftex
@tex
$$ x_{k+1} = ax_k + bu_k $$
@end tex
@end iftex
@ifinfo
@example
x(k+1) = a x(k) + b u(k)
@end example
@end ifinfo

@strong{Inputs}
@table @var
@item a
@var{n} by @var{n} matrix
@item b
@var{n} by @var{m} matrix
@end table

@strong{Output}
@table @var
@item m
@var{n} by @var{n} matrix, satisfies
@iftex
@tex
$$ ama^T - m + bb^T = 0 $$
@end tex
@end iftex
@ifinfo
@example
a m a' - m + b*b' = 0
@end example
@end ifinfo
@end table
@end deftypefn



@deftypefn {Function File} {} dlyap (@var{a}, @var{b})
Solve the discrete-time Lyapunov equation

@strong{Inputs}
@table @var
@item a
@var{n} by @var{n} matrix;
@item b
Matrix: @var{n} by @var{n}, @var{n} by @var{m}, or @var{p} by @var{n}
@end table

@strong{Output}
@table @var
@item x
matrix satisfying appropriate discrete time Lyapunov equation
@end table

Options:
@itemize @bullet
@item @var{b} is square: solve
@iftex
@tex
$$ axa^T - x + b = 0 $$
@end tex
@end iftex
@ifinfo
@code{a x a' - x + b = 0}
@end ifinfo
@item @var{b} is not square: @var{x} satisfies either
@iftex
@tex
$$ axa^T - x + bb^T = 0 $$
@end tex
@end iftex
@ifinfo
@example
a x a' - x + b b' = 0
@end example
@end ifinfo
@noindent
or
@iftex
@tex
$$ a^Txa - x + b^Tb = 0, $$
@end tex
@end iftex
@ifinfo
@example
a' x a - x + b' b = 0,
@end example
@end ifinfo
@noindent
whichever is appropriate
@end itemize

@strong{Method}
Uses Schur decomposition method as in Kitagawa,
@cite{An Algorithm for Solving the Matrix Equation @math{X = F X F' + S}},
International Journal of Control, Volume 25, Number 5, pages 745--753
(1977)

Column-by-column solution method as suggested in
Hammarling, @cite{Numerical Solution of the Stable, Non-Negative
Definite Lyapunov Equation}, @acronym{IMA} Journal of Numerical Analysis, Volume
2, pages 303--323 (1982)
@end deftypefn



@deftypefn {Function File} {@var{W} =} gram (@var{sys}, @var{mode})
@deftypefnx {Function File} {@var{Wc} =} gram (@var{a}, @var{b})
@code{gram (@var{sys}, 'c')} returns the controllability gramian of
the (continuous- or discrete-time) system @var{sys}
@code{gram (@var{sys}, 'o')} returns the observability gramian of the
(continuous- or discrete-time) system @var{sys}
@code{gram (@var{a}, @var{b})} returns the controllability gramian
@var{Wc} of the continuous-time system @math{dx/dt = a x + b u};
i.e., @var{Wc} satisfies @math{a Wc + m Wc' + b b' = 0}

@end deftypefn



@deftypefn {Function File} {} lyap (@var{a}, @var{b}, @var{c})
@deftypefnx {Function File} {} lyap (@var{a}, @var{b})
Solve the Lyapunov (or Sylvester) equation via the Bartels-Stewart
algorithm (Communications of the @acronym{ACM}, 1972)

If @var{a}, @var{b}, and @var{c} are specified, then @code{lyap} returns
the solution of the  Sylvester equation
@iftex
@tex
$$ A X + X B + C = 0 $$
@end tex
@end iftex
@ifinfo
@example
a x + x b + c = 0
@end example
@end ifinfo
If only @code{(a, b)} are specified, then @command{lyap} returns the
solution of the Lyapunov equation
@iftex
@tex
$$ A^T X + X A + B = 0 $$
@end tex
@end iftex
@ifinfo
@example
a' x + x a + b = 0
@end example
@end ifinfo
If @var{b} is not square, then @code{lyap} returns the solution of either
@iftex
@tex
$$ A^T X + X A + B^T B = 0 $$
@end tex
@end iftex
@ifinfo
@example
a' x + x a + b' b = 0
@end example
@end ifinfo
@noindent
or
@iftex
@tex
$$ A X + X A^T + B B^T = 0 $$
@end tex
@end iftex
@ifinfo
@example
a x + x a' + b b' = 0
@end example
@end ifinfo
@noindent
whichever is appropriate

Solves by using the Bartels-Stewart algorithm (1972)
@end deftypefn



@deftypefn {Function File} {} qzval (@var{a}, @var{b})
Compute generalized eigenvalues of the matrix pencil
@ifinfo
@example
(A - lambda B)
@end example
@end ifinfo
@iftex
@tex
$(A - \lambda B)$
@end tex
@end iftex

@var{a} and @var{b} must be real matrices

@code{qzval} is obsolete; use @code{qz} instead
@end deftypefn



@deftypefn {Function File} {@var{y} =} zgfmul (@var{a}, @var{b}, @var{c}, @var{d}, @var{x})
Compute product of @var{zgep} incidence matrix @math{F} with vector @var{x}
Used by @command{zgepbal} (in @command{zgscal}) as part of generalized conjugate gradient
iteration
@end deftypefn



@deftypefn {Function File} {} zgfslv (@var{n}, @var{m}, @var{p}, @var{b})
Solve system of equations for dense zgep problem
@end deftypefn



@deftypefn {Function File} {@var{zz} =} zginit (@var{a}, @var{b}, @var{c}, @var{d})
Construct right hand side vector @var{zz}
for the zero-computation generalized eigenvalue problem
balancing procedure.  Called by @command{zgepbal}
@end deftypefn



@deftypefn {Function File} {} zgreduce (@var{sys}, @var{meps})
Implementation of procedure REDUCE in (Emami-Naeini and Van Dooren,
Automatica, # 1982)
@end deftypefn



@deftypefn {Function File} {[@var{nonz}, @var{zer}] =} zgrownorm (@var{mat}, @var{meps})
Return @var{nonz} = number of rows of @var{mat} whose two norm
exceeds @var{meps}, and @var{zer} = number of rows of mat whose two
norm is less than @var{meps}
@end deftypefn



@deftypefn {Function File} {@var{x} =} zgscal (@var{f}, @var{z}, @var{n}, @var{m}, @var{p})
Generalized conjugate gradient iteration to
solve zero-computation generalized eigenvalue problem balancing equation
@math{fx=z}; called by @command{zgepbal}
@end deftypefn



@deftypefn {Function File} {[a, b] =} zgsgiv (@var{c}, @var{s}, @var{a}, @var{b})
Apply givens rotation c,s to row vectors @var{a}, @var{b}
No longer used in zero-balancing (__zgpbal__); kept for backward
compatibility
@end deftypefn



@deftypefn {Function File} {@var{x} =} zgshsr (@var{y})
Apply householder vector based on
@iftex
@tex
$ e^m $
@end tex
@end iftex
@ifinfo
@math{e^(m)}
@end ifinfo
to column vector @var{y}
Called by @command{zgfslv}
@end deftypefn



@strong{References}
@table @strong
@item  ZGEP
 Hodel, @cite{Computation of Zeros with Balancing}, 1992, Linear Algebra
 and its Applications
@item @strong{Generalized CG}
 Golub and Van Loan, @cite{Matrix Computations, 2nd ed} 1989.
@end table

@node sysprop
@chapter System Analysis-Properties

@deftypefn {Function File} {} analdemo ()
Octave Controls toolbox demo: State Space analysis demo
@end deftypefn



@deftypefn {Function File} {[@var{n}, @var{m}, @var{p}] =} abcddim (@var{a}, @var{b}, @var{c}, @var{d})
Check for compatibility of the dimensions of the matrices defining
the linear system
@iftex
@tex
$[A, B, C, D]$ corresponding to
$$
\eqalign{
{dx\over dt} &= A x + B u\cr
y &= C x + D u}
$$
@end tex
@end iftex
@ifinfo
[A, B, C, D] corresponding to

@example
dx/dt = a x + b u
y = c x + d u
@end example

@end ifinfo
or a similar discrete-time system

If the matrices are compatibly dimensioned, then @code{abcddim} returns

@table @var
@item n
The number of system states

@item m
The number of system inputs

@item p
The number of system outputs
@end table

Otherwise @code{abcddim} returns @var{n} = @var{m} = @var{p} = @minus{}1

Note: n = 0 (pure gain block) is returned without warning
See also: is_abcd
@end deftypefn



@deftypefn {Function File} {} ctrb (@var{sys}, @var{b})
@deftypefnx {Function File} {} ctrb (@var{a}, @var{b})
Build controllability matrix:
@iftex
@tex
$$ Q_s = [ B AB A^2B \ldots A^{n-1}B ] $$
@end tex
@end iftex
@ifinfo
@example
2       n-1
Qs = [ B AB A B ... A   B ]
@end example
@end ifinfo

of a system data structure or the pair (@var{a}, @var{b})

@command{ctrb} forms the controllability matrix
The numerical properties of @command{is_controllable}
are much better for controllability tests
@end deftypefn



@deftypefn {Function File} {} h2norm (@var{sys})
Computes the
@iftex
@tex
$ { \cal H }_2 $
@end tex
@end iftex
@ifinfo
H-2
@end ifinfo
norm of a system data structure (continuous time only)

Reference:
Doyle, Glover, Khargonekar, Francis, @cite{State-Space Solutions to Standard}
@iftex
@tex
$ { \cal H }_2 $ @cite{and} $ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-2 and H-infinity}
@end ifinfo
@cite{Control Problems}, @acronym{IEEE} @acronym{TAC} August 1989
@end deftypefn



@deftypefn {Function File} {[@var{g}, @var{gmin}, @var{gmax}] =} hinfnorm (@var{sys}, @var{tol}, @var{gmin}, @var{gmax}, @var{ptol})
Computes the
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
norm of a system data structure

@strong{Inputs}
@table @var
@item sys
system data structure
@item tol
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
norm search tolerance (default: 0.001)
@item gmin
minimum value for norm search (default: 1e-9)
@item gmax
maximum value for norm search (default: 1e+9)
@item ptol
pole tolerance:
@itemize @bullet
@item if sys is continuous, poles with
@iftex
@tex
$ \vert {\rm real}(pole) \vert < ptol \Vert H \Vert $
@end tex
@end iftex
@ifinfo
@math{ |real(pole))| < ptol*||H|| }
@end ifinfo
(@var{H} is appropriate Hamiltonian)
are considered to be on the imaginary axis

@item if sys is discrete, poles with
@iftex
@tex
$ \vert { \rm pole } - 1 \vert < ptol \Vert [ s_1 s_2 ] \Vert $
@end tex
@end iftex
@ifinfo
@math{|abs(pole)-1| < ptol*||[s1,s2]||}
@end ifinfo
(appropriate symplectic pencil)
are considered to be on the unit circle

@item Default value: 1e-9
@end itemize
@end table

@strong{Outputs}
@table @var
@item g
Computed gain, within @var{tol} of actual gain.  @var{g} is returned as Inf
if the system is unstable
@item gmin
@itemx gmax
Actual system gain lies in the interval [@var{gmin}, @var{gmax}]
@end table

References:
Doyle, Glover, Khargonekar, Francis, @cite{State-space solutions to standard}
@iftex
@tex
$ { \cal H }_2 $ @cite{and} $ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-2 and H-infinity}
@end ifinfo
@cite{control problems}, @acronym{IEEE} @acronym{TAC} August 1989;
Iglesias and Glover, @cite{State-Space approach to discrete-time}
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-infinity}
@end ifinfo
@cite{control}, Int. J. Control, vol 54, no. 5, 1991;
Zhou, Doyle, Glover, @cite{Robust and Optimal Control}, Prentice-Hall, 1996
@end deftypefn



@deftypefn {Function File} {} obsv (@var{sys}, @var{c})
@deftypefnx {Function File} {} obsv (@var{a}, @var{c})
Build observability matrix:
@iftex
@tex
$$ Q_b = \left[ \matrix{  C       \cr
CA    \cr
CA^2  \cr
\vdots  \cr
CA^{n-1} } \right ] $$
@end tex
@end iftex
@ifinfo
@example
@group
| C        |
| CA       |
Qb = | CA^2     |
| ...      |
| CA^(n-1) |
@end group
@end example
@end ifinfo
of a system data structure or the pair (@var{a}, @var{c})

The numerical properties of @command{is_observable}
are much better for observability tests
@end deftypefn



@deftypefn {Function File} {[@var{zer}, @var{pol}] =} pzmap (@var{sys})
Plots the zeros and poles of a system in the complex plane

@strong{Input}
@table @var
@item sys
System data structure
@end table

@strong{Outputs}
@table @var
@item pol
@item zer
if omitted, the poles and zeros are plotted on the screen
otherwise, @var{pol} and @var{zer} are returned as the
system poles and zeros (see @command{sys2zp} for a preferable function call)
@end table
@end deftypefn



@deftypefn {Function File} {@var{retval} =} is_abcd (@var{a}, @var{b}, @var{c}, @var{d})
Returns @var{retval} = 1 if the dimensions of @var{a}, @var{b},
@var{c}, @var{d} are compatible, otherwise @var{retval} = 0 with an
appropriate diagnostic message printed to the screen.  The matrices
@var{b}, @var{c}, or @var{d} may be omitted
See also: abcddim
@end deftypefn



@deftypefn {Function File} {[@var{retval}, @var{u}] =} is_controllable (@var{sys}, @var{tol})
@deftypefnx {Function File} {[@var{retval}, @var{u}] =} is_controllable (@var{a}, @var{b}, @var{tol})
Logical check for system controllability

@strong{Inputs}
@table @var
@item sys
system data structure
@item a
@itemx b
@var{n} by @var{n}, @var{n} by @var{m} matrices, respectively
@item tol
optional roundoff parameter.  Default value: @code{10*eps}
@end table

@strong{Outputs}
@table @var
@item retval
Logical flag; returns true (1) if the system @var{sys} or the
pair (@var{a}, @var{b}) is controllable, whichever was passed as input
arguments
@item u
@var{u} is an orthogonal basis of the controllable subspace
@end table

@strong{Method}
Controllability is determined by applying Arnoldi iteration with
complete re-orthogonalization to obtain an orthogonal basis of the
Krylov subspace
@example
span ([b,a*b,...,a^@{n-1@}*b])
@end example
The Arnoldi iteration is executed with @code{krylov} if the system
has a single input; otherwise a block Arnoldi iteration is performed
with @code{krylovb}
See also: size, rows, columns, length, ismatrix, isscalar, isvector, is_observable, is_stabilizable, is_detectable, krylov, krylovb
@end deftypefn



@deftypefn {Function File} {@var{retval} =} is_detectable (@var{a}, @var{c}, @var{tol}, @var{dflg})
@deftypefnx {Function File} {@var{retval} =} is_detectable (@var{sys}, @var{tol})
Test for detectability (observability of unstable modes) of (@var{a}, @var{c})

Returns 1 if the system @var{a} or the pair (@var{a}, @var{c}) is
detectable, 0 if not, and -1 if the system has unobservable modes at the
imaginary axis (unit circle for discrete-time systems)

@strong{See} @command{is_stabilizable} for detailed description of
arguments and computational method
See also: is_stabilizable, size, rows, columns, length, ismatrix, isscalar, isvector
@end deftypefn



@deftypefn {Function File} {[@var{retval}, @var{dgkf_struct} ] =} is_dgkf (@var{asys}, @var{nu}, @var{ny}, @var{tol} )
Determine whether a continuous time state space system meets
assumptions of @acronym{DGKF} algorithm
Partitions system into:
@example
[dx/dt]   [A  | Bw  Bu  ][w]
[ z   ] = [Cz | Dzw Dzu ][u]
[ y   ]   [Cy | Dyw Dyu ]
@end example
or similar discrete-time system
If necessary, orthogonal transformations @var{qw}, @var{qz} and nonsingular
transformations @var{ru}, @var{ry} are applied to respective vectors
@var{w}, @var{z}, @var{u}, @var{y} in order to satisfy @acronym{DGKF} assumptions
Loop shifting is used if @var{dyu} block is nonzero

@strong{Inputs}
@table @var
@item         asys
system data structure
@item           nu
number of controlled inputs
@item        ny
number of measured outputs
@item        tol
threshold for 0; default: 200*@code{eps}
@end table
@strong{Outputs}
@table @var
@item    retval
true(1) if system passes check, false(0) otherwise
@item    dgkf_struct
data structure of @command{is_dgkf} results.  Entries:
@table @var
@item      nw
@itemx     nz
dimensions of @var{w}, @var{z}
@item      a
system @math{A} matrix
@item      bw
(@var{n} x @var{nw}) @var{qw}-transformed disturbance input matrix
@item      bu
(@var{n} x @var{nu}) @var{ru}-transformed controlled input matrix;

@math{B = [Bw Bu]}
@item      cz
(@var{nz} x @var{n}) Qz-transformed error output matrix
@item      cy
(@var{ny} x @var{n}) @var{ry}-transformed measured output matrix

@math{C = [Cz; Cy]}
@item      dzu
@item      dyw
off-diagonal blocks of transformed system @math{D} matrix that enter
@var{z}, @var{y} from @var{u}, @var{w} respectively
@item      ru
controlled input transformation matrix
@item      ry
observed output transformation matrix
@item      dyu_nz
nonzero if the @var{dyu} block is nonzero
@item      dyu
untransformed @var{dyu} block
@item      dflg
nonzero if the system is discrete-time
@end table
@end table
@code{is_dgkf} exits with an error if the system is mixed
discrete/continuous

@strong{References}
@table @strong
@item [1]
Doyle, Glover, Khargonekar, Francis, @cite{State Space Solutions to Standard}
@iftex
@tex
$ { \cal H }_2 $ @cite{and} $ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-2 and H-infinity}
@end ifinfo
@cite{Control Problems}, @acronym{IEEE} @acronym{TAC} August 1989
@item [2]
Maciejowksi, J.M., @cite{Multivariable Feedback Design}, Addison-Wesley, 1989
@end table
@end deftypefn



@deftypefn {Function File} {@var{digital} =} is_digital (@var{sys}, @var{eflg})
Return nonzero if system is digital

@strong{Inputs}
@table @var
@item sys
System data structure
@item eflg
When equal to 0 (default value), exits with an error if the system
is mixed (continuous and discrete components); when equal to 1, print
a warning if the system is mixed (continuous and discrete); when equal
to 2, operate silently
@end table

@strong{Output}
@table @var
@item digital
When equal to 0, the system is purely continuous; when equal to 1, the
system is purely discrete; when equal to -1, the system is mixed continuous
and discrete
@end table
Exits with an error if @var{sys} is a mixed (continuous and discrete) system
@end deftypefn



@deftypefn {Function File} {[@var{retval}, @var{u}] =} is_observable (@var{a}, @var{c}, @var{tol})
@deftypefnx {Function File} {[@var{retval}, @var{u}] =} is_observable (@var{sys}, @var{tol})
Logical check for system observability

Default: tol = @code{tol = 10*norm(a,'fro')*eps}

Returns 1 if the system @var{sys} or the pair (@var{a}, @var{c}) is
observable, 0 if not

See @command{is_controllable} for detailed description of arguments
and default values
See also: size, rows, columns, length, ismatrix, isscalar, isvector
@end deftypefn



@deftypefn {Function File} {} is_sample (@var{ts})
Return true if @var{ts} is a valid sampling time
(real, scalar, > 0)
@end deftypefn



@deftypefn {Function File} {} is_siso (@var{sys})
Returns nonzero if the system data structure
@var{sys} is single-input, single-output
@end deftypefn



@deftypefn {Function File} {@var{retval} =} is_stabilizable (@var{sys}, @var{tol})
@deftypefnx {Function File} {@var{retval} =} is_stabilizable (@var{a}, @var{b}, @var{tol}, @var{dflg})
Logical check for system stabilizability (i.e., all unstable modes are controllable)
Returns 1 if the system is stabilizable, 0 if the system is not stabilizable, -1
if the system has non stabilizable modes at the imaginary axis (unit circle for
discrete-time systems

Test for stabilizability is performed via Hautus Lemma. If
@iftex
@tex
@var{dflg}$\neq$0
@end tex
@end iftex
@ifinfo
@var{dflg}!=0
@end ifinfo
assume that discrete-time matrices (a,b) are supplied
See also: size, rows, columns, length, ismatrix, isscalar, isvector, is_observable, is_stabilizable, is_detectable
@end deftypefn



@deftypefn {Function File} {} is_signal_list (@var{mylist})
Return true if @var{mylist} is a list of individual strings
@end deftypefn



@deftypefn {Function File} {} is_stable (@var{a}, @var{tol}, @var{dflg})
@deftypefnx {Function File} {} is_stable (@var{sys}, @var{tol})
Returns 1 if the matrix @var{a} or the system @var{sys}
is stable, or 0 if not

@strong{Inputs}
@table @var
@item  tol
is a roundoff parameter, set to 200*@code{eps} if omitted
@item dflg
Digital system flag (not required for system data structure):
@table @code
@item @var{dflg} != 0
stable if eig(a) is in the unit circle

@item @var{dflg} == 0
stable if eig(a) is in the open LHP (default)
@end table
@end table
See also: size, rows, columns, length, ismatrix, isscalar, isvector, is_observable, is_stabilizable, is_detectable, krylov, krylovb
@end deftypefn



@node systime
@chapter System Analysis-Time Domain

@deftypefn {Function File} {} c2d (@var{sys}, @var{opt}, @var{t})
@deftypefnx {Function File} {} c2d (@var{sys}, @var{t})

Converts the system data structure describing:
@iftex
@tex
$$ \dot x = A_cx + B_cu $$
@end tex
@end iftex
@ifinfo
@example

x = Ac x + Bc u
@end example
@end ifinfo
into a discrete time equivalent model:
@iftex
@tex
$$ x_{n+1} = A_dx_n + B_du_n $$
@end tex
@end iftex
@ifinfo
@example
x[n+1] = Ad x[n] + Bd u[n]
@end example
@end ifinfo
via the matrix exponential or bilinear transform

@strong{Inputs}
@table @var
@item sys
system data structure (may have both continuous time and discrete
time subsystems)
@item opt
string argument; conversion option (optional argument;
may be omitted as shown above)
@table @code
@item "ex"
use the matrix exponential (default)
@item "bi"
use the bilinear transformation
@iftex
@tex
$$ s = { 2(z-1) \over T(z+1) } $$
@end tex
@end iftex
@ifinfo
@example
2(z-1)
s = -----
T(z+1)
@end example
@end ifinfo
FIXME: This option exits with an error if @var{sys} is not purely
continuous. (The @code{ex} option can handle mixed systems.)
@item "matched"
Use the matched pole/zero equivalent transformation (currently only
works for purely continuous @acronym{SISO} systems)
@end table
@item t
sampling time; required if @var{sys} is purely continuous

@strong{Note} that if the second argument is not a string, @code{c2d()}
assumes that the second argument is @var{t} and performs
appropriate argument checks
@end table

@strong{Output}
@table @var
@item dsys
Discrete time equivalent via zero-order hold, sample each @var{t} sec
@end table

This function adds the suffix  @code{_d}
to the names of the new discrete states
@end deftypefn



@deftypefn {Function File} {} d2c (@var{sys}, @var{tol})
@deftypefnx {Function File} {} d2c (@var{sys}, @var{opt})
Convert a discrete (sub)system into a purely continuous one
The sampling time used is @code{sysgettsam(@var{sys})}

@strong{Inputs}
@table @var
@item   sys
system data structure with discrete components
@item   tol
Scalar value
Tolerance for convergence of default @code{"log"} option (see below)
@item   opt
conversion option.  Choose from:
@table @code
@item         "log"
(default) Conversion is performed via a matrix logarithm
Due to some problems with this computation, it is
followed by a steepest descent algorithm to identify continuous time
@var{a}, @var{b}, to get a better fit to the original data

If called as @code{d2c (@var{sys}, @var{tol})}, with @var{tol}
positive scalar, the @code{"log"} option is used.  The default value
for @var{tol} is @code{1e-8}
@item        "bi"
Conversion is performed via bilinear transform
@math{z = (1 + s T / 2)/(1 - s T / 2)} where @math{T} is the
system sampling time (see @code{sysgettsam})

FIXME: bilinear option exits with an error if @var{sys} is not purely
discrete
@end table
@end table
@strong{Output}
@table @var
@item csys
continuous time system (same dimensions and signal names as in @var{sys})
@end table
@end deftypefn



@deftypefn {Function File} {[@var{dsys}, @var{fidx}] =} dmr2d (@var{sys}, @var{idx}, @var{sprefix}, @var{ts2}, @var{cuflg})
convert a multirate digital system to a single rate digital system
states specified by @var{idx}, @var{sprefix} are sampled at @var{ts2}, all
others are assumed sampled at @var{ts1} = @code{sysgettsam (@var{sys})}

@strong{Inputs}
@table @var
@item   sys
discrete time system;
@code{dmr2d} exits with an error if @var{sys} is not discrete
@item   idx
indices or names of states with sampling time
@code{sysgettsam(@var{sys})} (may be empty); see @code{cellidx}
@item   sprefix
list of string prefixes of states with sampling time
@code{sysgettsam(@var{sys})} (may be empty)
@item   ts2
sampling time of states not specified by @var{idx}, @var{sprefix}
must be an integer multiple of @code{sysgettsam(@var{sys})}
@item   cuflg
"constant u flag" if @var{cuflg} is nonzero then the system inputs are
assumed to be constant over the revised sampling interval @var{ts2}
Otherwise, since the inputs can change during the interval
@var{t} in @math{[k ts2, (k+1) ts2]}, an additional set of inputs is
included in the revised B matrix so that these intersample inputs
may be included in the single-rate system
default @var{cuflg} = 1
@end table

@strong{Outputs}
@table @var
@item   dsys
equivalent discrete time system with sampling time @var{ts2}

The sampling time of sys is updated to @var{ts2}

if @var{cuflg}=0 then a set of additional inputs is added to
the system with suffixes _d1, @dots{}, _dn to indicate their
delay from the starting time k @var{ts2}, i.e
u = [u_1; u_1_d1; @dots{}, u_1_dn] where u_1_dk is the input
k*ts1 units of time after u_1 is sampled. (@var{ts1} is
the original sampling time of the discrete time system and
@var{ts2} = (n+1)*ts1)

@item   fidx
indices of "formerly fast" states specified by @var{idx} and @var{sprefix};
these states are updated to the new (slower) sampling interval @var{ts2}
@end table

@strong{WARNING} Not thoroughly tested yet; especially when
@var{cuflg} == 0
@end deftypefn



@deftypefn {Function File} {} damp (@var{p}, @var{tsam})
Displays eigenvalues, natural frequencies and damping ratios
of the eigenvalues of a matrix @var{p} or the @math{A} matrix of a
system @var{p}, respectively
If @var{p} is a system, @var{tsam} must not be specified
If @var{p} is a matrix and @var{tsam} is specified, eigenvalues
of @var{p} are assumed to be in @var{z}-domain
See also: eig
@end deftypefn



@deftypefn {Function File} {} dcgain (@var{sys}, @var{tol})
Returns dc-gain matrix. If dc-gain is infinite
an empty matrix is returned
The argument @var{tol} is an optional tolerance for the condition
number of the @math{A} Matrix in @var{sys} (default @var{tol} = 1.0e-10)
@end deftypefn



@deftypefn {Function File} {[@var{y}, @var{t}] =} impulse (@var{sys}, @var{inp}, @var{tstop}, @var{n})
Impulse response for a linear system
The system can be discrete or multivariable (or both)
If no output arguments are specified, @code{impulse}
produces a plot or the impulse response data for system @var{sys}

@strong{Inputs}
@table @var
@item sys
System data structure
@item inp
Index of input being excited
@item tstop
The argument @var{tstop} (scalar value) denotes the time when the
simulation should end
@item n
the number of data values

Both parameters @var{tstop} and @var{n} can be omitted and will be
computed from the eigenvalues of the A Matrix
@end table
@strong{Outputs}
@table @var
@item y
Values of the impulse response
@item t
Times of the impulse response
@end table
See also: step
@end deftypefn



@deftypefn {Function File} {[@var{y}, @var{t}] =} step (@var{sys}, @var{inp}, @var{tstop}, @var{n})
Step response for a linear system
The system can be discrete or multivariable (or both)
If no output arguments are specified, @code{step}
produces a plot or the step response data for system @var{sys}

@strong{Inputs}
@table @var
@item sys
System data structure
@item inp
Index of input being excited
@item tstop
The argument @var{tstop} (scalar value) denotes the time when the
simulation should end
@item n
the number of data values

Both parameters @var{tstop} and @var{n} can be omitted and will be
computed from the eigenvalues of the A Matrix
@end table
@strong{Outputs}
@table @var
@item y
Values of the step response
@item t
Times of the step response
@end table

When invoked with the output parameter @var{y} the plot is not displayed
See also: impulse
@end deftypefn



@node sysfreq
@chapter System Analysis-Frequency Domain

@strong{Demonstration/tutorial script}
@deftypefn {Function File} {} frdemo ()
Octave Control Toolbox demo: Frequency Response demo
@end deftypefn



@deftypefn {Function File} {[@var{mag}, @var{phase}, @var{w}] =} bode (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx})
If no output arguments are given: produce Bode plots of a system; otherwise,
compute the frequency response of a system data structure

@strong{Inputs}
@table @var
@item   sys
a system data structure (must be either purely continuous or discrete;
see is_digital)
@item   w
frequency values for evaluation

if @var{sys} is continuous, then bode evaluates @math{G(jw)} where
@math{G(s)} is the system transfer function

if @var{sys} is discrete, then bode evaluates G(@code{exp}(jwT)), where
@itemize @bullet
@item @math{T} is the system sampling time
@item @math{G(z)} is the system transfer function
@end itemize

@strong{Default} the default frequency range is selected as follows: (These
steps are @strong{not} performed if @var{w} is specified)
@enumerate
@item via routine __bodquist__, isolate all poles and zeros away from
@var{w}=0 (@var{jw}=0 or @math{@code{exp}(jwT)}=1) and select the frequency
range based on the breakpoint locations of the frequencies
@item if @var{sys} is discrete time, the frequency range is limited
to @math{jwT} in
@ifinfo
[0,2 pi /T]
@end ifinfo
@iftex
@tex
$[0,2\pi/T]$
@end tex
@end iftex
@item A "smoothing" routine is used to ensure that the plot phase does
not change excessively from point to point and that singular
points (e.g., crossovers from +/- 180) are accurately shown

@end enumerate
@item out_idx
@itemx in_idx

The names or indices of outputs and inputs to be used in the frequency
response.  See @code{sysprune}

@strong{Example}
@example
bode(sys,[],"y_3", @{"u_1","u_4"@});
@end example
@end table
@strong{Outputs}
@table @var
@item mag
@itemx phase
the magnitude and phase of the frequency response @math{G(jw)} or
@math{G(@code{exp}(jwT))} at the selected frequency values
@item w
the vector of frequency values used
@end table

@enumerate
@item If no output arguments are given, e.g.,
@example
bode(sys);
@end example
bode plots the results to the screen.  Descriptive labels are
automatically placed

Failure to include a concluding semicolon will yield some garbage
being printed to the screen (@code{ans = []})

@item If the requested plot is for an @acronym{MIMO} system, mag is set to
@math{||G(jw)||} or @math{||G(@code{exp}(jwT))||}
and phase information is not computed
@end enumerate
@end deftypefn



@deftypefn {Function File} {[@var{wmin}, @var{wmax}] =} bode_bounds (@var{zer}, @var{pol}, @var{dflg}, @var{tsam})
Get default range of frequencies based on cutoff frequencies of system
poles and zeros
Frequency range is the interval
@iftex
@tex
$ [ 10^{w_{min}}, 10^{w_{max}} ] $
@end tex
@end iftex
@ifinfo
[10^@var{wmin}, 10^@var{wmax}]
@end ifinfo

Used internally in @command{__freqresp__} (@command{bode}, @command{nyquist})
@end deftypefn



@deftypefn {Function File} {} freqchkw (@var{w})
Used by @command{__freqresp__} to check that input frequency vector @var{w}
is valid
Returns boolean value
@end deftypefn



@deftypefn {Function File} {@var{out} =} ltifr (@var{a}, @var{b}, @var{w})
@deftypefnx {Function File} {@var{out} =} ltifr (@var{sys}, @var{w})
Linear time invariant frequency response of single-input systems

@strong{Inputs}
@table @var
@item a
@itemx b
coefficient matrices of @math{dx/dt = A x + B u}
@item sys
system data structure
@item w
vector of frequencies
@end table
@strong{Output}
@table @var
@item out
frequency response, that is:
@end table
@iftex
@tex
$$ G(j\omega) = (j\omega I-A)^{-1}B $$
@end tex
@end iftex
@ifinfo
@example
-1
G(s) = (jw I-A) B
@end example
@end ifinfo
for complex frequencies @math{s = jw}
@end deftypefn



@deftypefn {Function File} {[@var{realp}, @var{imagp}, @var{w}] =} nyquist (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx}, @var{atol})
@deftypefnx {Function File} {} nyquist (@var{sys}, @var{w}, @var{out_idx}, @var{in_idx}, @var{atol})
Produce Nyquist plots of a system; if no output arguments are given, Nyquist
plot is printed to the screen

Compute the frequency response of a system

@strong{Inputs} (pass as empty to get default values)
@table @var
@item sys
system data structure (must be either purely continuous or discrete;
see @code{is_digital})
@item w
frequency values for evaluation
If sys is continuous, then bode evaluates @math{G(@var{jw})};
if sys is discrete, then bode evaluates @math{G(exp(@var{jwT}))},
where @var{T} is the system sampling time
@item default
the default frequency range is selected as follows: (These
steps are @strong{not} performed if @var{w} is specified)
@enumerate
@item via routine @command{__bodquist__}, isolate all poles and zeros away from
@var{w}=0 (@var{jw}=0 or @math{exp(@var{jwT})=1}) and select the frequency
range based on the breakpoint locations of the frequencies
@item if @var{sys} is discrete time, the frequency range is limited
to @var{jwT} in
@ifinfo
[0,2p*pi]
@end ifinfo
@iftex
@tex
$ [ 0,2  p \pi ] $
@end tex
@end iftex
@item A ``smoothing'' routine is used to ensure that the plot phase does
not change excessively from point to point and that singular
points (e.g., crossovers from +/- 180) are accurately shown
@end enumerate
@item   atol
for interactive nyquist plots: atol is a change-in-slope tolerance
for the of asymptotes (default = 0; 1e-2 is a good choice).  This allows
the user to ``zoom in'' on portions of the Nyquist plot too small to be
seen with large asymptotes
@end table
@strong{Outputs}
@table @var
@item    realp
@itemx   imagp
the real and imaginary parts of the frequency response
@math{G(jw)} or @math{G(exp(jwT))} at the selected frequency values
@item w
the vector of frequency values used
@end table

If no output arguments are given, nyquist plots the results to the screen
If @var{atol} != 0 and asymptotes are detected then the user is asked
interactively if they wish to zoom in (remove asymptotes)
Descriptive labels are automatically placed

Note: if the requested plot is for an @acronym{MIMO} system, a warning message is
presented; the returned information is of the magnitude
@iftex
@tex
$ \Vert G(jw) \Vert $ or $ \Vert G( {\rm exp}(jwT) \Vert $
@end tex
@end iftex
@ifinfo
||G(jw)|| or ||G(exp(jwT))||
@end ifinfo
only; phase information is not computed
@end deftypefn



@deftypefn {Function File} {[@var{mag}, @var{phase}, @var{w}] =} nichols (@var{sys}, @var{w}, @var{outputs}, @var{inputs})
Produce Nichols plot of a system

@strong{Inputs}
@table @var
@item sys
System data structure (must be either purely continuous or discrete;
see @command{is_digital})
@item w
Frequency values for evaluation
@itemize
@item if sys is continuous, then nichols evaluates @math{G(jw)}
@item if sys is discrete, then nichols evaluates @math{G(exp(jwT))},
where @var{T}=@var{sys}. @var{tsam} is the system sampling time
@item the default frequency range is selected as follows (These
steps are @strong{not} performed if @var{w} is specified):
@enumerate
@item via routine @command{__bodquist__}, isolate all poles and zeros away from
@var{w}=0 (@math{jw=0} or @math{exp(jwT)=1}) and select the frequency range
based on the breakpoint locations of the frequencies
@item if sys is discrete time, the frequency range is limited to jwT in
@iftex
@tex
$ [0, 2p\pi] $
@end tex
@end iftex
@ifinfo
[0,2p*pi]
@end ifinfo
@item A ``smoothing'' routine is used to ensure that the plot phase does
not change excessively from point to point and that singular points
(e.g., crossovers from +/- 180) are accurately shown
@end enumerate
@end itemize
@item outputs
@itemx inputs
the names or indices of the output(s) and input(s) to be used in the
frequency response; see @command{sysprune}
@end table
@strong{Outputs}
@table @var
@item mag
@itemx phase
The magnitude and phase of the frequency response @math{G(jw)} or
@math{G(exp(jwT))} at the selected frequency values
@item w
The vector of frequency values used
@end table
If no output arguments are given, @command{nichols} plots the results to the screen
Descriptive labels are automatically placed. See @command{xlabel},
@command{ylabel}, and @command{title}

Note: if the requested plot is for an @acronym{MIMO} system, @var{mag} is set to
@iftex
@tex
$ \Vert G(jw) \Vert $ or $ \Vert G( {\rm exp}(jwT) \Vert $
@end tex
@end iftex
@ifinfo
||G(jw)|| or ||G(exp(jwT))||
@end ifinfo
and phase information is not computed
@end deftypefn



@deftypefn {Function File} {[@var{zer}, @var{gain}] =} tzero (@var{a}, @var{b}, @var{c}, @var{d}, @var{opt})
@deftypefnx {Function File} {[@var{zer}, @var{gain}] =} tzero (@var{sys}, @var{opt})
Compute transmission zeros of a continuous system:
@iftex
@tex
$$ \dot x = Ax + Bu $$
$$ y = Cx + Du $$
@end tex
@end iftex
@ifinfo
@example

x = Ax + Bu
y = Cx + Du
@end example
@end ifinfo
or of a discrete one:
@iftex
@tex
$$ x_{k+1} = Ax_k + Bu_k $$
$$ y_k = Cx_k + Du_k $$
@end tex
@end iftex
@ifinfo
@example
x(k+1) = A x(k) + B u(k)
y(k)   = C x(k) + D u(k)
@end example
@end ifinfo

@strong{Outputs}
@table @var
@item zer
transmission zeros of the system
@item gain
leading coefficient (pole-zero form) of @acronym{SISO} transfer function
returns gain=0 if system is multivariable
@end table
@strong{References}
@enumerate
@item Emami-Naeini and Van Dooren, Automatica, 1982
@item Hodel, @cite{Computation of Zeros with Balancing}, 1992 Lin. Alg. Appl
@end enumerate
@end deftypefn



@deftypefn {Function File} {@var{zr} =} tzero2 (@var{a}, @var{b}, @var{c}, @var{d}, @var{bal})
Compute the transmission zeros of @var{a}, @var{b}, @var{c}, @var{d}

@var{bal} = balancing option (see balance); default is @code{"B"}

Needs to incorporate @command{mvzero} algorithm to isolate finite zeros;
use @command{tzero} instead
@end deftypefn



@node cacsd
@chapter Controller Design

@deftypefn {Function File} {} dgkfdemo ()
Octave Controls toolbox demo:
@iftex
@tex
$ { \cal H }_2 $/$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-2/H-infinity
@end ifinfo
options demos
@end deftypefn



@deftypefn {Function File} {} hinfdemo ()

@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
design demos for continuous @acronym{SISO} and @acronym{MIMO} systems and a
discrete system.  The @acronym{SISO} system is difficult to control because
it is non-minimum-phase and unstable. The second design example
controls the @command{jet707} plant, the linearized state space model of a
Boeing 707-321 aircraft at @var{v}=80 m/s
@iftex
@tex
($M = 0.26$, $G_{a0} = -3^{\circ}$, ${\alpha}_0 = 4^{\circ}$, ${\kappa}= 50^{\circ}$)
@end tex
@end iftex
@ifinfo
(@var{M} = 0.26, @var{Ga0} = -3 deg, @var{alpha0} = 4 deg, @var{kappa} = 50 deg)
@end ifinfo
Inputs: (1) thrust and (2) elevator angle
Outputs: (1) airspeed and (2) pitch angle. The discrete system is a
stable and second order

@table @asis
@item @acronym{SISO} plant:

@iftex
@tex
$$ G(s) = { s-2 \over (s+2) (s-1) } $$
@end tex
@end iftex
@ifinfo
@example
@group
s - 2
G(s) = --------------
(s + 2)(s - 1)
@end group
@end example
@end ifinfo

@smallexample
@group

+----+
-------------------->| W1 |---> v1
z   |                    +----+
----|-------------+
|             |
|    +---+    v   y  +----+
u *--->| G |--->O--*-->| W2 |---> v2
|    +---+       |   +----+
|                |
|    +---+       |
-----| K |<-------
+---+
@end group
@end smallexample

@iftex
@tex
$$ { \rm min } \Vert T_{vz} \Vert _\infty $$
@end tex
@end iftex
@ifinfo
@example
min || T   ||
vz   infty
@end example
@end ifinfo

@var{W1} und @var{W2} are the robustness and performance weighting
functions

@item @acronym{MIMO} plant:
The optimal controller minimizes the
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
norm of the
augmented plant @var{P} (mixed-sensitivity problem):
@smallexample
@group
w
1 -----------+
|                   +----+
+---------------------->| W1 |----> z1
w         |   |                   +----+
2 ------------------------+
|   |            |
|   v   +----+   v      +----+
+--*-->o-->| G  |-->o--*-->| W2 |---> z2
|          +----+      |   +----+
|                      |
^                      v
u                       y (to K)
(from controller K)
@end group
@end smallexample

@iftex
@tex
$$ \left [ \matrix{ z_1 \cr
z_2 \cr
y   } \right ] =
P \left [ \matrix{ w_1 \cr
w_2 \cr
u   } \right ] $$
@end tex
@end iftex
@ifinfo
@smallexample
@group
+    +           +    +
| z  |           | w  |
|  1 |           |  1 |
| z  | = [ P ] * | w  |
|  2 |           |  2 |
| y  |           | u  |
+    +           +    +
@end group
@end smallexample
@end ifinfo

@item Discrete system:
This is not a true discrete design. The design is carried out
in continuous time while the effect of sampling is described by
a bilinear transformation of the sampled system
This method works quite well if the sampling period is ``small''
compared to the plant time constants

@item The continuous plant:
@iftex
@tex
$$ G(s) = { 1 \over (s+2)(s+1) } $$
@end tex
@end iftex

@ifinfo
@example
@group
1
G (s) = --------------
k      (s + 2)(s + 1)

@end group
@end example
@end ifinfo

is discretised with a @acronym{ZOH} (Sampling period = @var{Ts} = 1 second):
@iftex
@tex
$$ G(z) = { 0.199788z + 0.073498 \over (z - 0.36788) (z - 0.13534) } $$
@end tex
@end iftex
@ifinfo
@example
@group

0.199788z + 0.073498
G(z) = --------------------------
(z - 0.36788)(z - 0.13534)
@end group
@end example
@end ifinfo

@smallexample
@group

+----+
-------------------->| W1 |---> v1
z   |                    +----+
----|-------------+
|             |
|    +---+    v      +----+
*--->| G |--->O--*-->| W2 |---> v2
|    +---+       |   +----+
|                |
|    +---+       |
-----| K |<-------
+---+
@end group
@end smallexample
@iftex
@tex
$$ { \rm min } \Vert T_{vz} \Vert _\infty $$
@end tex
@end iftex
@ifinfo
@example
min || T   ||
vz   infty
@end example
@end ifinfo
@var{W1} and @var{W2} are the robustness and performance weighting
functions
@end table
@end deftypefn



@deftypefn {Function File} {[@var{l}, @var{m}, @var{p}, @var{e}] =} dlqe (@var{a}, @var{g}, @var{c}, @var{sigw}, @var{sigv}, @var{z})
Construct the linear quadratic estimator (Kalman filter) for the
discrete time system
@iftex
@tex
$$
x_{k+1} = A x_k + B u_k + G w_k
$$
$$
y_k = C x_k + D u_k + v_k
$$
@end tex
@end iftex
@ifinfo

@example
x[k+1] = A x[k] + B u[k] + G w[k]
y[k] = C x[k] + D u[k] + v[k]
@end example

@end ifinfo
where @var{w}, @var{v} are zero-mean gaussian noise processes with
respective intensities @code{@var{sigw} = cov (@var{w}, @var{w})} and
@code{@var{sigv} = cov (@var{v}, @var{v})}

If specified, @var{z} is @code{cov (@var{w}, @var{v})}.  Otherwise
@code{cov (@var{w}, @var{v}) = 0}

The observer structure is
@iftex
@tex
$$
z_{k|k} = z_{k|k-1} + l (y_k - C z_{k|k-1} - D u_k)
$$
$$
z_{k+1|k} = A z_{k|k} + B u_k
$$
@end tex
@end iftex
@ifinfo

@example
z[k|k] = z[k|k-1] + L (y[k] - C z[k|k-1] - D u[k])
z[k+1|k] = A z[k|k] + B u[k]
@end example
@end ifinfo

@noindent
The following values are returned:

@table @var
@item l
The observer gain,
@iftex
@tex
$(A - ALC)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{a}@var{l}@var{c})
@end ifinfo
is stable

@item m
The Riccati equation solution

@item p
The estimate error covariance after the measurement update

@item e
The closed loop poles of
@iftex
@tex
$(A - ALC)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{a}@var{l}@var{c})
@end ifinfo
@end table
@end deftypefn



@deftypefn {Function File} {[@var{k}, @var{p}, @var{e}] =} dlqr (@var{a}, @var{b}, @var{q}, @var{r}, @var{z})
Construct the linear quadratic regulator for the discrete time system
@iftex
@tex
$$
x_{k+1} = A x_k + B u_k
$$
@end tex
@end iftex
@ifinfo

@example
x[k+1] = A x[k] + B u[k]
@end example

@end ifinfo
to minimize the cost functional
@iftex
@tex
$$
J = \sum x^T Q x + u^T R u
$$
@end tex
@end iftex
@ifinfo

@example
J = Sum (x' Q x + u' R u)
@end example
@end ifinfo

@noindent
@var{z} omitted or
@iftex
@tex
$$
J = \sum x^T Q x + u^T R u + 2 x^T Z u
$$
@end tex
@end iftex
@ifinfo

@example
J = Sum (x' Q x + u' R u + 2 x' Z u)
@end example

@end ifinfo
@var{z} included

The following values are returned:

@table @var
@item k
The state feedback gain,
@iftex
@tex
$(A - B K)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{b}@var{k})
@end ifinfo
is stable

@item p
The solution of algebraic Riccati equation

@item e
The closed loop poles of
@iftex
@tex
$(A - B K)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{b}@var{k})
@end ifinfo
@end table
@end deftypefn



@deftypefn {Function File} {[@var{Lp}, @var{Lf}, @var{P}, @var{Z}] =} dkalman (@var{A}, @var{G}, @var{C}, @var{Qw}, @var{Rv}, @var{S})
Construct the linear quadratic estimator (Kalman predictor) for the
discrete time system
@iftex
@tex
$$
x_{k+1} = A x_k + B u_k + G w_k
$$
$$
y_k = C x_k + D u_k + v_k
$$
@end tex
@end iftex
@ifinfo

@example
x[k+1] = A x[k] + B u[k] + G w[k]
y[k] = C x[k] + D u[k] + v[k]
@end example

@end ifinfo
where @var{w}, @var{v} are zero-mean gaussian noise processes with
respective intensities @code{@var{Qw} = cov (@var{w}, @var{w})} and
@code{@var{Rv} = cov (@var{v}, @var{v})}

If specified, @var{S} is @code{cov (@var{w}, @var{v})}.  Otherwise
@code{cov (@var{w}, @var{v}) = 0}

The observer structure is
@iftex
@tex
$x_{k+1|k} = A x_{k|k-1} + B u_k + L_p (y_k - C x_{k|k-1} - D u_k)$
$x_{k|k} = x_{k|k} + L_f (y_k - C x_{k|k-1} - D u_k)$
@end tex
@end iftex
@ifinfo

@example
x[k+1|k] = A x[k|k-1] + B u[k] + LP (y[k] - C x[k|k-1] - D u[k])
x[k|k] = x[k|k-1] + LF (y[k] - C x[k|k-1] - D u[k])
@end example
@end ifinfo

@noindent
The following values are returned:

@table @var
@item Lp
The predictor gain,
@iftex
@tex
$(A - L_p C)$
@end tex
@end iftex
@ifinfo
(@var{A} - @var{Lp} @var{C})
@end ifinfo
is stable

@item Lf
The filter gain

@item P
The Riccati solution
@iftex
@tex
$P = E \{(x - x_{n|n-1})(x - x_{n|n-1})'\}$
@end tex
@end iftex

@ifinfo
P = E [(x - x[n|n-1])(x - x[n|n-1])']
@end ifinfo

@item Z
The updated error covariance matrix
@iftex
@tex
$Z = E \{(x - x_{n|n})(x - x_{n|n})'\}$
@end tex
@end iftex

@ifinfo
Z = E [(x - x[n|n])(x - x[n|n])']
@end ifinfo
@end table
@end deftypefn



@deftypefn {Function File} {[@var{K}, @var{gain}, @var{kc}, @var{kf}, @var{pc}, @var{pf}] =} h2syn (@var{asys}, @var{nu}, @var{ny}, @var{tol})
Design
@iftex
@tex
$ { \cal H }_2 $
@end tex
@end iftex
@ifinfo
H-2
@end ifinfo
optimal controller per procedure in
Doyle, Glover, Khargonekar, Francis, @cite{State-Space Solutions to Standard}
@iftex
@tex
$ { \cal H }_2 $ @cite{and} $ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-2 and H-infinity}
@end ifinfo
@cite{Control Problems}, @acronym{IEEE} @acronym{TAC} August 1989

Discrete-time control per Zhou, Doyle, and Glover, @cite{Robust and optimal control}, Prentice-Hall, 1996

@strong{Inputs}
@table @var
@item asys
system data structure (see ss, sys2ss)
@itemize @bullet
@item controller is implemented for continuous time systems
@item controller is @strong{not} implemented for discrete time systems
@end itemize
@item nu
number of controlled inputs
@item ny
number of measured outputs
@item tol
threshold for 0.  Default: 200*@code{eps}
@end table

@strong{Outputs}
@table @var
@item    k
system controller
@item    gain
optimal closed loop gain
@item    kc
full information control (packed)
@item    kf
state estimator (packed)
@item    pc
@acronym{ARE} solution matrix for regulator subproblem
@item    pf
@acronym{ARE} solution matrix for filter subproblem
@end table
@end deftypefn



@deftypefn {Function File} {@var{K} =} hinf_ctr (@var{dgs}, @var{f}, @var{h}, @var{z}, @var{g})
Called by @code{hinfsyn} to compute the
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
optimal controller

@strong{Inputs}
@table @var
@item dgs
data structure returned by @code{is_dgkf}
@item f
@itemx h
feedback and filter gain (not partitioned)
@item g
final gamma value
@end table
@strong{Outputs}
@table @var
@item K
controller (system data structure)
@end table

Do not attempt to use this at home; no argument checking performed
@end deftypefn



@deftypefn {Function File} {[@var{k}, @var{g}, @var{gw}, @var{xinf}, @var{yinf}] =} hinfsyn (@var{asys}, @var{nu}, @var{ny}, @var{gmin}, @var{gmax}, @var{gtol}, @var{ptol}, @var{tol})

@strong{Inputs} input system is passed as either
@table @var
@item asys
system data structure (see @command{ss}, @command{sys2ss})
@itemize @bullet
@item controller is implemented for continuous time systems
@item controller is @strong{not} implemented for discrete time systems  (see
bilinear transforms in @command{c2d}, @command{d2c})
@end itemize
@item nu
number of controlled inputs
@item ny
number of measured outputs
@item gmin
initial lower bound on
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
optimal gain
@item gmax
initial upper bound on
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
Optimal gain
@item gtol
Gain threshold.  Routine quits when @var{gmax}/@var{gmin} < 1+tol
@item ptol
poles with @code{abs(real(pole))}
@iftex
@tex
$ < ptol \Vert H \Vert $
@end tex
@end iftex
@ifinfo
< ptol*||H||
@end ifinfo
(@var{H} is appropriate
Hamiltonian) are considered to be on the imaginary axis
Default: 1e-9
@item tol
threshold for 0.  Default: 200*@code{eps}

@var{gmax}, @var{min}, @var{tol}, and @var{tol} must all be positive scalars
@end table
@strong{Outputs}
@table @var
@item k
System controller
@item g
Designed gain value
@item gw
Closed loop system
@item xinf
@acronym{ARE} solution matrix for regulator subproblem
@item yinf
@acronym{ARE} solution matrix for filter subproblem
@end table

References:
@enumerate
@item Doyle, Glover, Khargonekar, Francis, @cite{State-Space Solutions
to Standard}
@iftex
@tex
$ { \cal H }_2 $ @cite{and} $ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-2 and H-infinity}
@end ifinfo
@cite{Control Problems}, @acronym{IEEE} @acronym{TAC} August 1989

@item Maciejowksi, J.M., @cite{Multivariable feedback design},
Addison-Wesley, 1989, @acronym{ISBN} 0-201-18243-2

@item Keith Glover and John C. Doyle, @cite{State-space formulae for all
stabilizing controllers that satisfy an}
@iftex
@tex
$ { \cal H }_\infty $@cite{norm}
@end tex
@end iftex
@ifinfo
@cite{H-infinity-norm}
@end ifinfo
@cite{bound and relations to risk sensitivity},
Systems & Control Letters 11, Oct. 1988, pp 167--172
@end enumerate
@end deftypefn



@deftypefn {Function File} {[@var{retval}, @var{pc}, @var{pf}] =} hinfsyn_chk (@var{a}, @var{b1}, @var{b2}, @var{c1}, @var{c2}, @var{d12}, @var{d21}, @var{g}, @var{ptol})
Called by @code{hinfsyn} to see if gain @var{g} satisfies conditions in
Theorem 3 of
Doyle, Glover, Khargonekar, Francis, @cite{State Space Solutions to Standard}
@iftex
@tex
$ { \cal H }_2 $ @cite{and} $ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
@cite{H-2 and H-infinity}
@end ifinfo
@cite{Control Problems}, @acronym{IEEE} @acronym{TAC} August 1989

@strong{Warning:} do not attempt to use this at home; no argument
checking performed

@strong{Inputs}

As returned by @code{is_dgkf}, except for:
@table @var
@item g
candidate gain level
@item ptol
as in @code{hinfsyn}
@end table

@strong{Outputs}
@table @var
@item retval
1 if g exceeds optimal Hinf closed loop gain, else 0
@item pc
solution of ``regulator''
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
@acronym{ARE}
@item pf
solution of ``filter''
@iftex
@tex
$ { \cal H }_\infty $
@end tex
@end iftex
@ifinfo
H-infinity
@end ifinfo
@acronym{ARE}
@end table
Do not attempt to use this at home; no argument checking performed
@end deftypefn



@deftypefn {Function File} {[@var{xinf}, @var{x_ha_err}] =} hinfsyn_ric (@var{a}, @var{bb}, @var{c1}, @var{d1dot}, @var{r}, @var{ptol})
Forms
@example
xx = ([bb; -c1'*d1dot]/r) * [d1dot'*c1 bb'];
Ha = [a 0*a; -c1'*c1 - a'] - xx;
@end example
and solves associated Riccati equation
The error code @var{x_ha_err} indicates one of the following
conditions:
@table @asis
@item 0
successful
@item 1
@var{xinf} has imaginary eigenvalues
@item 2
@var{hx} not Hamiltonian
@item 3
@var{xinf} has infinite eigenvalues (numerical overflow)
@item 4
@var{xinf} not symmetric
@item 5
@var{xinf} not positive definite
@item 6
@var{r} is singular
@end table
@end deftypefn



@deftypefn {Function File} {[@var{k}, @var{p}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{sigw}, @var{sigv}, @var{z})
Construct the linear quadratic estimator (Kalman filter) for the
continuous time system
@iftex
@tex
$$
{dx\over dt} = A x + G u
$$
$$
y = C x + v
$$
@end tex
@end iftex
@ifinfo

@example
dx
-- = A x + G u
dt

y = C x + v
@end example

@end ifinfo
where @var{w} and @var{v} are zero-mean gaussian noise processes with
respective intensities

@example
sigw = cov (w, w)
sigv = cov (v, v)
@end example

The optional argument @var{z} is the cross-covariance
@code{cov (@var{w}, @var{v})}.  If it is omitted,
@code{cov (@var{w}, @var{v}) = 0} is assumed

Observer structure is @code{dz/dt = A z + B u + k (y - C z - D u)}

The following values are returned:

@table @var
@item k
The observer gain,
@iftex
@tex
$(A - K C)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{k}@var{c})
@end ifinfo
is stable

@item p
The solution of algebraic Riccati equation

@item e
The vector of closed loop poles of
@iftex
@tex
$(A - K C)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{k}@var{c})
@end ifinfo
@end table
@end deftypefn



@deftypefn {Function File} {[@var{k}, @var{q1}, @var{p1}, @var{ee}, @var{er}] =} lqg (@var{sys}, @var{sigw}, @var{sigv}, @var{q}, @var{r}, @var{in_idx})
Design a linear-quadratic-gaussian optimal controller for the system
@example
dx/dt = A x + B u + G w       [w]=N(0,[Sigw 0    ])
y = C x + v               [v]  (    0   Sigv ])
@end example
or
@example
x(k+1) = A x(k) + B u(k) + G w(k)   [w]=N(0,[Sigw 0    ])
y(k) = C x(k) + v(k)              [v]  (    0   Sigv ])
@end example

@strong{Inputs}
@table @var
@item  sys
system data structure
@item  sigw
@itemx  sigv
intensities of independent Gaussian noise processes (as above)
@item  q
@itemx  r
state, control weighting respectively.  Control @acronym{ARE} is
@item  in_idx
names or indices of controlled inputs (see @command{sysidx}, @command{cellidx})

default: last dim(R) inputs are assumed to be controlled inputs, all
others are assumed to be noise inputs
@end table
@strong{Outputs}
@table @var
@item    k
system data structure format @acronym{LQG} optimal controller (Obtain A, B, C
matrices with @command{sys2ss}, @command{sys2tf}, or @command{sys2zp} as
appropriate)
@item    p1
Solution of control (state feedback) algebraic Riccati equation
@item    q1
Solution of estimation algebraic Riccati equation
@item    ee
Estimator poles
@item    es
Controller poles
@end table
See also: h2syn, lqe, lqr
@end deftypefn



@deftypefn {Function File} {[@var{k}, @var{p}, @var{e}] =} lqr (@var{a}, @var{b}, @var{q}, @var{r}, @var{z})
construct the linear quadratic regulator for the continuous time system
@iftex
@tex
$$
{dx\over dt} = A x + B u
$$
@end tex
@end iftex
@ifinfo

@example
dx
-- = A x + B u
dt
@end example

@end ifinfo
to minimize the cost functional
@iftex
@tex
$$
J = \int_0^\infty x^T Q x + u^T R u
$$
@end tex
@end iftex
@ifinfo

@example
infinity
/
J = |  x' Q x + u' R u
/
t=0
@end example
@end ifinfo

@noindent
@var{z} omitted or
@iftex
@tex
$$
J = \int_0^\infty x^T Q x + u^T R u + 2 x^T Z u
$$
@end tex
@end iftex
@ifinfo

@example
infinity
/
J = |  x' Q x + u' R u + 2 x' Z u
/
t=0
@end example

@end ifinfo
@var{z} included

The following values are returned:

@table @var
@item k
The state feedback gain,
@iftex
@tex
$(A - B K)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{b}@var{k})
@end ifinfo
is stable and minimizes the cost functional

@item p
The stabilizing solution of appropriate algebraic Riccati equation

@item e
The vector of the closed loop poles of
@iftex
@tex
$(A - B K)$
@end tex
@end iftex
@ifinfo
(@var{a} - @var{b}@var{k})
@end ifinfo
@end table

@strong{Reference}
Anderson and Moore, @cite{Optimal control: linear quadratic methods},
Prentice-Hall, 1990, pp. 56--58
@end deftypefn



@deftypefn {Function File} {[@var{y}, @var{x}] =} lsim (@var{sys}, @var{u}, @var{t}, @var{x0})
Produce output for a linear simulation of a system; produces
a plot for the output of the system, @var{sys}

@var{u} is an array that contains the system's inputs.  Each row in @var{u}
corresponds to a different time step.  Each column in @var{u} corresponds to a
different input.  @var{t} is an array that contains the time index of the
system; @var{t} should be regularly spaced.  If initial conditions are required
on the system, the @var{x0} vector should be added to the argument list

When the lsim function is invoked a plot is not displayed;
however, the data is returned in @var{y} (system output)
and @var{x} (system states)
@end deftypefn



@deftypefn {Function File} {@var{K} =} place (@var{sys}, @var{p})
@deftypefnx {Function File} {@var{K} =} place (@var{a}, @var{b}, @var{p})
Computes the matrix @var{K} such that if the state
is feedback with gain @var{K}, then the eigenvalues  of the closed loop
system (i.e. @math{A-BK}) are those specified in the vector @var{p}

Version: Beta (May-1997): If you have any comments, please let me know
(see the file place.m for my address)
@end deftypefn



@node misc
@chapter Miscellaneous Functions (Not yet properly filed/documented)

@deftypefn {Function File} {} axis2dlim (@var{axdata})
Determine axis limits for 2-D data (column vectors); leaves a 10%
margin around the plots
Inserts margins of +/- 0.1 if data is one-dimensional
(or a single point)

@strong{Input}
@table @var
@item axdata
@var{n} by 2 matrix of data [@var{x}, @var{y}]
@end table

@strong{Output}
@table @var
@item axvec
Vector of axis limits appropriate for call to @command{axis} function
@end table
@end deftypefn



@deftypefn {Function File} {} moddemo (@var{inputs})
Octave Control toolbox demo: Model Manipulations demo
@end deftypefn



@deftypefn {Function File} {} prompt (@var{str})
Prompt user to continue

@strong{Input}
@table @var
@item str
Input string. Its default value is:
@example
\n ---- Press a key to  continue ---
@end example
@end table
@end deftypefn



@deftypefn {Function File} {} rldemo (@var{inputs})
Octave Control toolbox demo: Root Locus demo
@end deftypefn



@deftypefn {Function File} {[@var{rldata}, @var{k}] =} rlocus (@var{sys}[, @var{increment}, @var{min_k}, @var{max_k}])

Display root locus plot of the specified @acronym{SISO} system
@example
@group
-----   ---     --------
--->| + |---|k|---->| SISO |----------->
-----   ---     --------        |
- ^                             |
|_____________________________|
@end group
@end example

@strong{Inputs}
@table @var
@item sys
system data structure
@item min_k
Minimum value of @var{k}
@item max_k
Maximum value of @var{k}
@item increment
The increment used in computing gain values
@end table

@strong{Outputs}

Plots the root locus to the screen
@table @var
@item rldata
Data points plotted: in column 1 real values, in column 2 the imaginary values
@item k
Gains for real axis break points
@end table
@end deftypefn



@deftypefn {Function File} {[@var{yy}, @var{idx}] =} sortcom (@var{xx}[, @var{opt}])
Sort a complex vector

@strong{Inputs}
@table @var
@item xx
Complex vector
@item opt
sorting option:
@table @code
@item "re"
Real part (default);
@item "mag"
By magnitude;
@item "im"
By imaginary part
@end table
if @var{opt} is not chosen as @code{"im"}, then complex conjugate pairs are grouped together,
@math{a - jb} followed by @math{a + jb}
@end table

@strong{Outputs}
@table @var
@item yy
Sorted values
@item idx
Permutation vector: @code{yy = xx(idx)}
@end table
@end deftypefn



@deftypefn {Function File} {[@var{num}, @var{den}] =} ss2tf (@var{a}, @var{b}, @var{c}, @var{d})
Conversion from transfer function to state-space
The state space system:
@iftex
@tex
$$ \dot x = Ax + Bu $$
$$ y = Cx + Du $$
@end tex
@end iftex
@ifinfo
@example

x = Ax + Bu
y = Cx + Du
@end example
@end ifinfo

is converted to a transfer function:
@iftex
@tex
$$ G(s) = { { \rm num }(s) \over { \rm den }(s) } $$
@end tex
@end iftex
@ifinfo
@example

num(s)
G(s)=-------
den(s)
@end example
@end ifinfo

used internally in system data structure format manipulations
@end deftypefn



@deftypefn {Function File} {[@var{pol}, @var{zer}, @var{k}] =} ss2zp (@var{a}, @var{b}, @var{c}, @var{d})
Converts a state space representation to a set of poles and zeros;
@var{k} is a gain associated with the zeros

Used internally in system data structure format manipulations
@end deftypefn



@deftypefn {Function File} {} starp (@var{P}, @var{K}, @var{ny}, @var{nu})

Redheffer star product or upper/lower LFT, respectively
@example
@group

+-------+
--------->|       |--------->
|   P   |
+--->|       |---+  ny
|    +-------+   |
+-------------------+
|  |
+----------------+  |
|                   |
|    +-------+      |
+--->|       |------+ nu
|   K   |
--------->|       |--------->
+-------+
@end group
@end example
If @var{ny} and @var{nu} ``consume'' all inputs and outputs of
@var{K} then the result is a lower fractional transformation
If @var{ny} and @var{nu} ``consume'' all inputs and outputs of
@var{P} then the result is an upper fractional transformation

@var{ny} and/or @var{nu} may be negative (i.e. negative feedback)
@end deftypefn



@deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}] =} tf2ss (@var{num}, @var{den})
Conversion from transfer function to state-space
The state space system:
@iftex
@tex
$$ \dot x = Ax + Bu $$
$$ y = Cx + Du $$
@end tex
@end iftex
@ifinfo
@example

x = Ax + Bu
y = Cx + Du
@end example
@end ifinfo
is obtained from a transfer function:
@iftex
@tex
$$ G(s) = { { \rm num }(s) \over { \rm den }(s) } $$
@end tex
@end iftex
@ifinfo
@example
num(s)
G(s)=-------
den(s)
@end example
@end ifinfo

The vector @var{den} must contain only one row, whereas the vector
@var{num} may contain as many rows as there are outputs @var{y} of
the system. The state space system matrices obtained from this function
will be in controllable canonical form as described in @cite{Modern Control
Theory}, (Brogan, 1991)
@end deftypefn



@deftypefn {Function File} {[@var{zer}, @var{pol}, @var{k}] =} tf2zp (@var{num}, @var{den})
Converts transfer functions to poles-and-zero representations

Returns the zeros and poles of the @acronym{SISO} system defined
by @var{num}/@var{den}
@var{k} is a gain associated with the system zeros
@end deftypefn



@deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}] =} zp2ss (@var{zer}, @var{pol}, @var{k})
Conversion from zero / pole to state space

@strong{Inputs}
@table @var
@item zer
@itemx pol
Vectors of (possibly) complex poles and zeros of a transfer
function. Complex values must come in conjugate pairs
(i.e., @math{x+jy} in @var{zer} means that @math{x-jy} is also in @var{zer})
The number of zeros must not exceed the number of poles
@item k
Real scalar (leading coefficient)
@end table

@strong{Outputs}
@table @var
@item @var{a}
@itemx @var{b}
@itemx @var{c}
@itemx @var{d}
The state space system, in the form:
@iftex
@tex
$$ \dot x = Ax + Bu $$
$$ y = Cx + Du $$
@end tex
@end iftex
@ifinfo
@example

x = Ax + Bu
y = Cx + Du
@end example
@end ifinfo
@end table
@end deftypefn



@deftypefn {Function File} {[@var{num}, @var{den}] =} zp2tf (@var{zer}, @var{pol}, @var{k})
Converts zeros / poles to a transfer function

@strong{Inputs}
@table @var
@item zer
@itemx pol
Vectors of (possibly complex) poles and zeros of a transfer
function.  Complex values must appear in conjugate pairs
@item k
Real scalar (leading coefficient)
@end table
@end deftypefn



@bye

@c Local Variables: ***
@c Mode: texinfo ***
@c End: ***