changeset 9550:f905dcc528fb octave-forge

control: work on documentation
author paramaniac
date Thu, 01 Mar 2012 17:45:35 +0000
parents b89d165a0663
children c2199c8eb019
files main/control/devel/anderson.m main/control/devel/madievski.m main/control/inst/Anderson.m main/control/inst/Madievski.m main/control/inst/btamodred.m
diffstat 5 files changed, 220 insertions(+), 210 deletions(-) [+]
line wrap: on
line diff
--- a/main/control/devel/anderson.m	Thu Mar 01 17:23:50 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-%% -*- texinfo -*-
-%% Frequency-weighted coprime factorization controller reduction.
-
-% ===============================================================================
-% Coprime Factorization Controller Reduction     Lukas Reichlin     December 2011
-% ===============================================================================
-% Reference: Anderson, B.D.O.: Controller Reduction: Concepts and Approaches
-%            IEEE Transactions of Automatic Control, Vol. 34, No. 8, August 1989
-% ===============================================================================
-
-% Tabula Rasa
-clear all, close all, clc
-
-% Plant
-A = [ -0.161      -6.004      -0.58215    -9.9835     -0.40727    -3.982       0.0         0.0
-       1.0         0.0         0.0         0.0         0.0         0.0         0.0         0.0
-       0.0         1.0         0.0         0.0         0.0         0.0         0.0         0.0
-       0.0         0.0         1.0         0.0         0.0         0.0         0.0         0.0
-       0.0         0.0         0.0         1.0         0.0         0.0         0.0         0.0
-       0.0         0.0         0.0         0.0         1.0         0.0         0.0         0.0
-       0.0         0.0         0.0         0.0         0.0         1.0         0.0         0.0
-       0.0         0.0         0.0         0.0         0.0         0.0         1.0         0.0     ];
-
-B = [  1.0
-       0.0  
-       0.0  
-       0.0  
-       0.0  
-       0.0  
-       0.0  
-       0.0 ];
-
-C = [  0.0         0.0         6.4432e-3   2.3196e-3   7.1252e-2   1.0002      0.10455     0.99551 ];
-
-G = ss (A, B, C);
-
-% LQG Design
-H = [  0.0         0.0         0.0         0.0         0.55       11.0         1.32       18.0     ];
-
-q1 = 1e-6;
-q2 = 100;   % [100, 1000, 2000]
-
-Q = q1 * H.' * H;
-R = 1;
-
-W = q2 * B * B.';
-V = 1;
-
-F = lqr (G, Q, R)
-L = lqr (G.', W, V).'
-
-% Coprime Factorization using Balanced Truncation Approximation
-figure (1)
-for k = 8:-1:2
-  Kr = cfconred (G, F, L, k);   % 'method', 'bfsr-bta'
-  T = feedback (G*Kr);
-  step (T, 200)
-  hold on
-endfor
-hold off
-
-% Coprime Factorization using Singular Perturbation Approximation
-figure (2)
-for k = 8:-1:2
-  Kr = cfconred (G, F, L, k, 'method', 'bfsr-spa');
-  T = feedback (G*Kr);
-  step (T, 200)
-  hold on
-endfor
-hold off
-
-% Frequency-Weighted Coprime Factorization using BTA
-figure (3)
-for k = 8:-1:2
-  Kr = fwcfconred (G, F, L, k);
-  T = feedback (G*Kr);
-  step (T, 300)
-  hold on
-endfor
-hold off
--- a/main/control/devel/madievski.m	Thu Mar 01 17:23:50 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-%% -*- texinfo -*-
-%% Frequency-weighted controller reduction.
-
-% ===============================================================================
-% Frequency Weighted Controller Reduction       Lukas Reichlin      December 2011
-% ===============================================================================
-% Reference: Madievski, A.G. and Anderson, B.D.O.
-%            Sampled-Data Controller Reduction Procedure
-%            IEEE Transactions of Automatic Control
-%            Vol. 40, No. 11, November 1995
-% ===============================================================================
-
-% Tabula Rasa
-clear all, close all, clc
-
-% Plant
-Ap1 = [  0.0         1.0
-         0.0         0.0     ];
-
-Ap2 = [ -0.015       0.765
-        -0.765      -0.015   ];
-
-Ap3 = [ -0.028       1.410
-        -1.410      -0.028   ];
-
-Ap4 = [ -0.04        1.85
-        -1.85       -0.04    ];
-
-Ap = blkdiag (Ap1, Ap2, Ap3, Ap4);
-
-Bp = [   0.026
-        -0.251
-         0.033
-        -0.886
-        -4.017
-         0.145
-         3.604
-         0.280   ];
-
-Cp = [  -0.996      -0.105       0.261       0.009      -0.001      -0.043       0.002      -0.026   ];
-
-Dp = [   0.0     ];
-
-P = ss (Ap, Bp, Cp, Dp);
-
-% Controller
-Ac = [  -0.4077      0.9741      0.1073      0.0131      0.0023     -0.0186     -0.0003     -0.0098
-        -0.0977     -0.1750      0.0215     -0.0896     -0.0260      0.0057      0.0109     -0.0105
-         0.0011      0.0218     -0.0148      0.7769      0.0034     -0.0013     -0.0014      0.0011
-        -0.0361     -0.5853     -0.7701     -0.3341     -0.0915      0.0334      0.0378     -0.0290
-        -0.1716     -2.6546     -0.0210     -1.4467     -0.4428      1.5611      0.1715     -0.1318
-        -0.0020      0.0950      0.0029      0.0523     -1.3950     -0.0338     -0.0062      0.0045
-         0.1607      2.3824      0.0170      1.2979      0.3721     -0.1353     -0.1938      1.9685
-        -0.0006      0.1837      0.0048      0.1010      0.0289     -0.0111     -1.8619     -0.0311  ];
-
-Bc = [  -0.4105
-        -0.0868
-        -0.0004
-         0.0036
-         0.0081
-        -0.0085
-        -0.0004
-        -0.0132  ];
-
-Cc = [  -0.0447     -0.6611     -0.0047     -0.3601     -0.1033      0.0375      0.0427     -0.0329  ];
-
-Dc = [   0.0     ];
-
-K = ss (Ac, Bc, Cc, Dc);
-
-% Controller Reduction
-Kr4 = spaconred (P, K, 4, 'feedback', '-')
-Kr2 = spaconred (P, K, 2, 'feedback', '-')
-
-% Open Loop
-L = P * K;
-Lr4 = P * Kr4;
-Lr2 = P * Kr2;
-
-% Closed Loop
-T = feedback (L);
-Tr4 = feedback (Lr4);
-Tr2 = feedback (Lr2);
-
-% Frequency Range
-w = {1e-2, 1e1};
-
-% Bode Plot of Controller
-[mag, pha, w] = bode (K, w);
-[magr4, phar4, wr4] = bode (Kr4, w);
-[magr2, phar2, wr2] = bode (Kr2, w);
-
-mag = 20 * log10 (mag);
-magr4 = 20 * log10 (magr4);
-magr2 = 20 * log10 (magr2);
-
-figure (1)
-subplot (2, 1, 1)
-semilogx (w, mag, wr4, magr4, wr2, magr2)
-axis ('tight')
-ylim (__axis_margin__ (ylim))
-grid ('on')
-title ('Bode Diagrams of K and Kr')
-ylabel ('Magnitude [dB]')
-
-subplot (2, 1, 2)
-semilogx (w, pha, wr4, phar4, wr2, phar2)
-axis ('tight')
-ylim (__axis_margin__ (ylim))
-grid ('on')
-xlabel ('Frequency [rad/s]')
-ylabel ('Phase [deg]')
-legend ('K (8 states)', 'Kr (4 states)', 'Kr (2 states)', 'location', 'southwest')
-    
-% Step Response of Closed Loop
-[y, t] = step (T, 100);
-[yr4, tr4] = step (Tr4, 100);
-[yr2, tr2] = step (Tr2, 100);
-
-figure (2)
-plot (t, y, tr4, yr4, tr2, yr2)
-grid ('on')
-title ('Step Response of Closed Loop')
-xlabel ('Time [s]')
-ylabel ('Output [-]')
-legend ('K (8 states)', 'Kr (4 states)', 'Kr (2 states)', 'Location', 'SouthEast')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/control/inst/Anderson.m	Thu Mar 01 17:45:35 2012 +0000
@@ -0,0 +1,80 @@
+%% -*- texinfo -*-
+%% Frequency-weighted coprime factorization controller reduction.
+
+% ===============================================================================
+% Coprime Factorization Controller Reduction     Lukas Reichlin     December 2011
+% ===============================================================================
+% Reference: Anderson, B.D.O.: Controller Reduction: Concepts and Approaches
+%            IEEE Transactions of Automatic Control, Vol. 34, No. 8, August 1989
+% ===============================================================================
+
+% Tabula Rasa
+clear all, close all, clc
+
+% Plant
+A = [ -0.161      -6.004      -0.58215    -9.9835     -0.40727    -3.982       0.0         0.0
+       1.0         0.0         0.0         0.0         0.0         0.0         0.0         0.0
+       0.0         1.0         0.0         0.0         0.0         0.0         0.0         0.0
+       0.0         0.0         1.0         0.0         0.0         0.0         0.0         0.0
+       0.0         0.0         0.0         1.0         0.0         0.0         0.0         0.0
+       0.0         0.0         0.0         0.0         1.0         0.0         0.0         0.0
+       0.0         0.0         0.0         0.0         0.0         1.0         0.0         0.0
+       0.0         0.0         0.0         0.0         0.0         0.0         1.0         0.0     ];
+
+B = [  1.0
+       0.0  
+       0.0  
+       0.0  
+       0.0  
+       0.0  
+       0.0  
+       0.0 ];
+
+C = [  0.0         0.0         6.4432e-3   2.3196e-3   7.1252e-2   1.0002      0.10455     0.99551 ];
+
+G = ss (A, B, C);
+
+% LQG Design
+H = [  0.0         0.0         0.0         0.0         0.55       11.0         1.32       18.0     ];
+
+q1 = 1e-6;
+q2 = 100;   % [100, 1000, 2000]
+
+Q = q1 * H.' * H;
+R = 1;
+
+W = q2 * B * B.';
+V = 1;
+
+F = lqr (G, Q, R)
+L = lqr (G.', W, V).'
+
+% Coprime Factorization using Balanced Truncation Approximation
+figure (1)
+for k = 8:-1:2
+  Kr = cfconred (G, F, L, k);   % 'method', 'bfsr-bta'
+  T = feedback (G*Kr);
+  step (T, 200)
+  hold on
+endfor
+hold off
+
+% Coprime Factorization using Singular Perturbation Approximation
+figure (2)
+for k = 8:-1:2
+  Kr = cfconred (G, F, L, k, 'method', 'bfsr-spa');
+  T = feedback (G*Kr);
+  step (T, 200)
+  hold on
+endfor
+hold off
+
+% Frequency-Weighted Coprime Factorization using BTA
+figure (3)
+for k = 8:-1:2
+  Kr = fwcfconred (G, F, L, k);
+  T = feedback (G*Kr);
+  step (T, 300)
+  hold on
+endfor
+hold off
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/control/inst/Madievski.m	Thu Mar 01 17:45:35 2012 +0000
@@ -0,0 +1,126 @@
+%% -*- texinfo -*-
+%% Frequency-weighted controller reduction.
+
+% ===============================================================================
+% Frequency Weighted Controller Reduction       Lukas Reichlin      December 2011
+% ===============================================================================
+% Reference: Madievski, A.G. and Anderson, B.D.O.
+%            Sampled-Data Controller Reduction Procedure
+%            IEEE Transactions of Automatic Control
+%            Vol. 40, No. 11, November 1995
+% ===============================================================================
+
+% Tabula Rasa
+clear all, close all, clc
+
+% Plant
+Ap1 = [  0.0         1.0
+         0.0         0.0     ];
+
+Ap2 = [ -0.015       0.765
+        -0.765      -0.015   ];
+
+Ap3 = [ -0.028       1.410
+        -1.410      -0.028   ];
+
+Ap4 = [ -0.04        1.85
+        -1.85       -0.04    ];
+
+Ap = blkdiag (Ap1, Ap2, Ap3, Ap4);
+
+Bp = [   0.026
+        -0.251
+         0.033
+        -0.886
+        -4.017
+         0.145
+         3.604
+         0.280   ];
+
+Cp = [  -0.996      -0.105       0.261       0.009      -0.001      -0.043       0.002      -0.026   ];
+
+Dp = [   0.0     ];
+
+P = ss (Ap, Bp, Cp, Dp);
+
+% Controller
+Ac = [  -0.4077      0.9741      0.1073      0.0131      0.0023     -0.0186     -0.0003     -0.0098
+        -0.0977     -0.1750      0.0215     -0.0896     -0.0260      0.0057      0.0109     -0.0105
+         0.0011      0.0218     -0.0148      0.7769      0.0034     -0.0013     -0.0014      0.0011
+        -0.0361     -0.5853     -0.7701     -0.3341     -0.0915      0.0334      0.0378     -0.0290
+        -0.1716     -2.6546     -0.0210     -1.4467     -0.4428      1.5611      0.1715     -0.1318
+        -0.0020      0.0950      0.0029      0.0523     -1.3950     -0.0338     -0.0062      0.0045
+         0.1607      2.3824      0.0170      1.2979      0.3721     -0.1353     -0.1938      1.9685
+        -0.0006      0.1837      0.0048      0.1010      0.0289     -0.0111     -1.8619     -0.0311  ];
+
+Bc = [  -0.4105
+        -0.0868
+        -0.0004
+         0.0036
+         0.0081
+        -0.0085
+        -0.0004
+        -0.0132  ];
+
+Cc = [  -0.0447     -0.6611     -0.0047     -0.3601     -0.1033      0.0375      0.0427     -0.0329  ];
+
+Dc = [   0.0     ];
+
+K = ss (Ac, Bc, Cc, Dc);
+
+% Controller Reduction
+Kr4 = spaconred (P, K, 4, 'feedback', '-')
+Kr2 = spaconred (P, K, 2, 'feedback', '-')
+
+% Open Loop
+L = P * K;
+Lr4 = P * Kr4;
+Lr2 = P * Kr2;
+
+% Closed Loop
+T = feedback (L);
+Tr4 = feedback (Lr4);
+Tr2 = feedback (Lr2);
+
+% Frequency Range
+w = {1e-2, 1e1};
+
+% Bode Plot of Controller
+[mag, pha, w] = bode (K, w);
+[magr4, phar4, wr4] = bode (Kr4, w);
+[magr2, phar2, wr2] = bode (Kr2, w);
+
+mag = 20 * log10 (mag);
+magr4 = 20 * log10 (magr4);
+magr2 = 20 * log10 (magr2);
+
+figure (1)
+subplot (2, 1, 1)
+semilogx (w, mag, wr4, magr4, wr2, magr2)
+axis ('tight')
+ylim (__axis_margin__ (ylim))
+grid ('on')
+title ('Bode Diagrams of K and Kr')
+ylabel ('Magnitude [dB]')
+
+subplot (2, 1, 2)
+semilogx (w, pha, wr4, phar4, wr2, phar2)
+axis ('tight')
+ylim (__axis_margin__ (ylim))
+grid ('on')
+xlabel ('Frequency [rad/s]')
+ylabel ('Phase [deg]')
+legend ('K (8 states)', 'Kr (4 states)', 'Kr (2 states)', 'location', 'southwest')
+    
+% Step Response of Closed Loop
+[y, t] = step (T, 100);
+[yr4, tr4] = step (Tr4, 100);
+[yr2, tr2] = step (Tr2, 100);
+
+figure (2)
+plot (t, y, tr4, yr4, tr2, yr2)
+grid ('on')
+title ('Step Response of Closed Loop')
+xlabel ('Time [s]')
+ylabel ('Output [-]')
+legend ('K (8 states)', 'Kr (4 states)', 'Kr (2 states)', 'Location', 'SouthEast')
--- a/main/control/inst/btamodred.m	Thu Mar 01 17:23:50 2012 +0000
+++ b/main/control/inst/btamodred.m	Thu Mar 01 17:45:35 2012 +0000
@@ -180,14 +180,24 @@
 ## @item 'equil', 'scale'
 ## Boolean indicating whether equilibration (scaling) should be
 ## performed on system @var{G} prior to order reduction.
+## This is done by state transformations.
 ## Default value is true if @code{G.scaled == false} and
 ## false if @code{G.scaled == true}.
+## Note that for @acronym{MIMO} models,.
 ## @end table
 ##
-##
-## UNSTABLE (from bstmodred)
-##
-## MIMO (from bstmodred)
+## For @acronym{MIMO} models, proper scaling of both inputs and outputs
+## is of utmost importance.  The input and output scaling can @strong{not}
+## be done by the equilibration option or the @command{prescale} command
+## because these functions perform state transformations only.
+## Signals should not be scaled simply to the range of, say, -1 to +1.
+## For all inputs (or outputs), a change from +1 to +2 should be of the
+## same importance for the model.
+## Think of a chemical reactor, the importance could be the cost to control this
+## reactor.  Then a change on each input from +1.5 to +2.0 would cost 50$.
+## Otherwise, important behaviour of @var{G} could be neglected just because
+## the corresponding signals have smaller numbers than those of other,
+## less important effects of @var{G}.
 ##
 ## Approximation Properties:
 ## @itemize @bullet