Mercurial > forge
changeset 9476:bd763272440e octave-forge
move finished functions from package "control-devel" to "control" (2)
author | paramaniac |
---|---|
date | Wed, 22 Feb 2012 19:46:06 +0000 |
parents | f4cb218d8bea |
children | 331814898d0c |
files | extra/control-devel/devel/anderson.m extra/control-devel/devel/balancmr.m extra/control-devel/devel/balred.m extra/control-devel/devel/bstmr.m extra/control-devel/devel/hankelmr.m extra/control-devel/devel/madievski.m extra/control-devel/devel/makefile_conred.m extra/control-devel/devel/makefile_modred.m main/control/devel/anderson.m main/control/devel/balancmr.m main/control/devel/balred.m main/control/devel/bstmr.m main/control/devel/hankelmr.m main/control/devel/madievski.m main/control/devel/makefile_conred.m main/control/devel/makefile_modred.m |
diffstat | 16 files changed, 434 insertions(+), 434 deletions(-) [+] |
line wrap: on
line diff
--- a/extra/control-devel/devel/anderson.m Wed Feb 22 19:42:49 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/extra/control-devel/devel/balancmr.m Wed Feb 22 19:42:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -## Copyright (C) 2012 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} balancmr (@var{G}, @dots{}) -## Wrapper for @command{btamodred}. -## @end deftypefn - -## Author: Lukas Reichlin <lukas.reichlin@gmail.com> -## Created: January 2012 -## Version: 0.1 - -function [Gr, info] = balancmr (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("control:wrapper", - "control: 'balancmr' is just a compatibility wrapper for 'btamodred'"); - endif - - [Gr, info] = btamodred (varargin{:}); - -endfunction
--- a/extra/control-devel/devel/balred.m Wed Feb 22 19:42:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -## Copyright (C) 2012 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} balred (@var{G}, @dots{}) -## Wrapper for @command{spamodred}. -## @end deftypefn - -## Author: Lukas Reichlin <lukas.reichlin@gmail.com> -## Created: January 2012 -## Version: 0.1 - -function [Gr, info] = balred (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("control:wrapper", - "control: 'balred' is just a compatibility wrapper for 'spamodred'"); - endif - - [Gr, info] = spamodred (varargin{:}); - -endfunction
--- a/extra/control-devel/devel/bstmr.m Wed Feb 22 19:42:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -## Copyright (C) 2012 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} bstmr (@var{G}, @dots{}) -## Wrapper for @command{bstmodred}. -## @end deftypefn - -## Author: Lukas Reichlin <lukas.reichlin@gmail.com> -## Created: January 2012 -## Version: 0.1 - -function [Gr, info] = bstmr (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("control:wrapper", - "control: 'bstmr' is just a compatibility wrapper for 'bstmodred'"); - endif - - [Gr, info] = bstmodred (varargin{:}); - -endfunction
--- a/extra/control-devel/devel/hankelmr.m Wed Feb 22 19:42:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -## Copyright (C) 2012 Lukas F. Reichlin -## -## This file is part of LTI Syncope. -## -## LTI Syncope is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## LTI Syncope is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} hankelmr (@var{G}, @dots{}) -## Wrapper for @command{hnamodred}. -## @end deftypefn - -## Author: Lukas Reichlin <lukas.reichlin@gmail.com> -## Created: January 2012 -## Version: 0.1 - -function [Gr, info] = hankelmr (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("control:wrapper", - "control: 'hankelmr' is just a compatibility wrapper for 'hnamodred'"); - endif - - [Gr, info] = hnamodred (varargin{:}); - -endfunction
--- a/extra/control-devel/devel/madievski.m Wed Feb 22 19:42:49 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')
--- a/extra/control-devel/devel/makefile_conred.m Wed Feb 22 19:42:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -## ============================================================================== -## Developer Makefile for OCT-files -## ============================================================================== -## USAGE: * fetch control-devel from Octave-Forge by svn -## * add control-devel/inst, control-devel/src and control-devel/devel -## to your Octave path (by an .octaverc file) -## * run makefile_conred -## ============================================================================== - -homedir = pwd (); -develdir = fileparts (which ("makefile_conred")); -srcdir = [develdir, "/../src"]; -cd (srcdir); - -mkoctfile slsb16ad.cc \ - SB16AD.f TB01ID.f SB16AY.f TB01KD.f AB09IX.f \ - MB04OD.f MB01WD.f SB03OD.f MB03UD.f AB05PD.f \ - AB09DD.f AB07ND.f TB01LD.f AB05QD.f SB03OU.f \ - MA02AD.f MB03QX.f select.f MB01YD.f MB01ZD.f \ - SB03OT.f MB04OY.f MB03QD.f MB04ND.f MB03QY.f \ - SB03OR.f SB03OY.f SB04PX.f MB04NY.f SB03OV.f \ - "$(mkoctfile -p LAPACK_LIBS)" \ - "$(mkoctfile -p BLAS_LIBS)" - -mkoctfile slsb16bd.cc \ - SB16BD.f AB09AD.f AB09BD.f SB08GD.f SB08HD.f \ - TB01ID.f AB09AX.f MA02GD.f AB09BX.f TB01WD.f \ - MA02DD.f MB03UD.f select.f AB09DD.f SB03OU.f \ - MA02AD.f SB03OT.f MB04ND.f MB04OD.f SB03OR.f \ - SB03OY.f SB04PX.f MB04NY.f MB04OY.f SB03OV.f \ - "$(mkoctfile -p LAPACK_LIBS)" \ - "$(mkoctfile -p BLAS_LIBS)" - -mkoctfile slsb16cd.cc \ - SB16CD.f SB16CY.f AB09IX.f SB03OD.f MB02UD.f \ - AB09DD.f MA02AD.f MB03UD.f select.f SB03OU.f \ - MB01SD.f SB03OT.f MB04ND.f MB04OD.f SB03OR.f \ - SB03OY.f SB04PX.f MB04NY.f MB04OY.f SB03OV.f \ - "$(mkoctfile -p LAPACK_LIBS)" \ - "$(mkoctfile -p BLAS_LIBS)" - -system ("rm *.o"); -cd (homedir); -
--- a/extra/control-devel/devel/makefile_modred.m Wed Feb 22 19:42:49 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -## ============================================================================== -## Developer Makefile for OCT-files -## ============================================================================== -## USAGE: * fetch control-devel from Octave-Forge by svn -## * add control-devel/inst, control-devel/src and control-devel/devel -## to your Octave path (by an .octaverc file) -## * run makefile_modred -## ============================================================================== - -homedir = pwd (); -develdir = fileparts (which ("makefile_modred")); -srcdir = [develdir, "/../src"]; -cd (srcdir); - -mkoctfile slab09hd.cc \ - slicotlibrary.a \ - "$(mkoctfile -p LAPACK_LIBS)" \ - "$(mkoctfile -p BLAS_LIBS)" - -mkoctfile slab09id.cc \ - slicotlibrary.a \ - "$(mkoctfile -p LAPACK_LIBS)" \ - "$(mkoctfile -p BLAS_LIBS)" - -mkoctfile slab09jd.cc \ - slicotlibrary.a \ - "$(mkoctfile -p LAPACK_LIBS)" \ - "$(mkoctfile -p BLAS_LIBS)" - -system ("rm *.o"); -cd (homedir); -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/anderson.m Wed Feb 22 19:46:06 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/devel/balancmr.m Wed Feb 22 19:46:06 2012 +0000 @@ -0,0 +1,38 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} balancmr (@var{G}, @dots{}) +## Wrapper for @command{btamodred}. +## @end deftypefn + +## Author: Lukas Reichlin <lukas.reichlin@gmail.com> +## Created: January 2012 +## Version: 0.1 + +function [Gr, info] = balancmr (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("control:wrapper", + "control: 'balancmr' is just a compatibility wrapper for 'btamodred'"); + endif + + [Gr, info] = btamodred (varargin{:}); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/balred.m Wed Feb 22 19:46:06 2012 +0000 @@ -0,0 +1,38 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} balred (@var{G}, @dots{}) +## Wrapper for @command{spamodred}. +## @end deftypefn + +## Author: Lukas Reichlin <lukas.reichlin@gmail.com> +## Created: January 2012 +## Version: 0.1 + +function [Gr, info] = balred (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("control:wrapper", + "control: 'balred' is just a compatibility wrapper for 'spamodred'"); + endif + + [Gr, info] = spamodred (varargin{:}); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/bstmr.m Wed Feb 22 19:46:06 2012 +0000 @@ -0,0 +1,38 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} bstmr (@var{G}, @dots{}) +## Wrapper for @command{bstmodred}. +## @end deftypefn + +## Author: Lukas Reichlin <lukas.reichlin@gmail.com> +## Created: January 2012 +## Version: 0.1 + +function [Gr, info] = bstmr (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("control:wrapper", + "control: 'bstmr' is just a compatibility wrapper for 'bstmodred'"); + endif + + [Gr, info] = bstmodred (varargin{:}); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/hankelmr.m Wed Feb 22 19:46:06 2012 +0000 @@ -0,0 +1,38 @@ +## Copyright (C) 2012 Lukas F. Reichlin +## +## This file is part of LTI Syncope. +## +## LTI Syncope is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## LTI Syncope is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn{Function File} {[@var{Gr}, @var{info}] =} hankelmr (@var{G}, @dots{}) +## Wrapper for @command{hnamodred}. +## @end deftypefn + +## Author: Lukas Reichlin <lukas.reichlin@gmail.com> +## Created: January 2012 +## Version: 0.1 + +function [Gr, info] = hankelmr (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("control:wrapper", + "control: 'hankelmr' is just a compatibility wrapper for 'hnamodred'"); + endif + + [Gr, info] = hnamodred (varargin{:}); + +endfunction
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/madievski.m Wed Feb 22 19:46:06 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')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/makefile_conred.m Wed Feb 22 19:46:06 2012 +0000 @@ -0,0 +1,44 @@ +## ============================================================================== +## Developer Makefile for OCT-files +## ============================================================================== +## USAGE: * fetch control-devel from Octave-Forge by svn +## * add control-devel/inst, control-devel/src and control-devel/devel +## to your Octave path (by an .octaverc file) +## * run makefile_conred +## ============================================================================== + +homedir = pwd (); +develdir = fileparts (which ("makefile_conred")); +srcdir = [develdir, "/../src"]; +cd (srcdir); + +mkoctfile slsb16ad.cc \ + SB16AD.f TB01ID.f SB16AY.f TB01KD.f AB09IX.f \ + MB04OD.f MB01WD.f SB03OD.f MB03UD.f AB05PD.f \ + AB09DD.f AB07ND.f TB01LD.f AB05QD.f SB03OU.f \ + MA02AD.f MB03QX.f select.f MB01YD.f MB01ZD.f \ + SB03OT.f MB04OY.f MB03QD.f MB04ND.f MB03QY.f \ + SB03OR.f SB03OY.f SB04PX.f MB04NY.f SB03OV.f \ + "$(mkoctfile -p LAPACK_LIBS)" \ + "$(mkoctfile -p BLAS_LIBS)" + +mkoctfile slsb16bd.cc \ + SB16BD.f AB09AD.f AB09BD.f SB08GD.f SB08HD.f \ + TB01ID.f AB09AX.f MA02GD.f AB09BX.f TB01WD.f \ + MA02DD.f MB03UD.f select.f AB09DD.f SB03OU.f \ + MA02AD.f SB03OT.f MB04ND.f MB04OD.f SB03OR.f \ + SB03OY.f SB04PX.f MB04NY.f MB04OY.f SB03OV.f \ + "$(mkoctfile -p LAPACK_LIBS)" \ + "$(mkoctfile -p BLAS_LIBS)" + +mkoctfile slsb16cd.cc \ + SB16CD.f SB16CY.f AB09IX.f SB03OD.f MB02UD.f \ + AB09DD.f MA02AD.f MB03UD.f select.f SB03OU.f \ + MB01SD.f SB03OT.f MB04ND.f MB04OD.f SB03OR.f \ + SB03OY.f SB04PX.f MB04NY.f MB04OY.f SB03OV.f \ + "$(mkoctfile -p LAPACK_LIBS)" \ + "$(mkoctfile -p BLAS_LIBS)" + +system ("rm *.o"); +cd (homedir); +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/control/devel/makefile_modred.m Wed Feb 22 19:46:06 2012 +0000 @@ -0,0 +1,32 @@ +## ============================================================================== +## Developer Makefile for OCT-files +## ============================================================================== +## USAGE: * fetch control-devel from Octave-Forge by svn +## * add control-devel/inst, control-devel/src and control-devel/devel +## to your Octave path (by an .octaverc file) +## * run makefile_modred +## ============================================================================== + +homedir = pwd (); +develdir = fileparts (which ("makefile_modred")); +srcdir = [develdir, "/../src"]; +cd (srcdir); + +mkoctfile slab09hd.cc \ + slicotlibrary.a \ + "$(mkoctfile -p LAPACK_LIBS)" \ + "$(mkoctfile -p BLAS_LIBS)" + +mkoctfile slab09id.cc \ + slicotlibrary.a \ + "$(mkoctfile -p LAPACK_LIBS)" \ + "$(mkoctfile -p BLAS_LIBS)" + +mkoctfile slab09jd.cc \ + slicotlibrary.a \ + "$(mkoctfile -p LAPACK_LIBS)" \ + "$(mkoctfile -p BLAS_LIBS)" + +system ("rm *.o"); +cd (homedir); +