From: <par...@us...> - 2010-09-15 00:13:47
|
Revision: 7722 http://octave.svn.sourceforge.net/octave/?rev=7722&view=rev Author: paramaniac Date: 2010-09-15 00:13:40 +0000 (Wed, 15 Sep 2010) Log Message: ----------- control: try sticking to GNU coding standards (more to come) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m trunk/octave-forge/main/control/inst/@ss/__sysprune__.m trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m trunk/octave-forge/main/control/inst/@tf/__sysprune__.m trunk/octave-forge/main/control/inst/__frequency_response__.m Added Paths: ----------- trunk/octave-forge/main/control/inst/@lti/__lti_group__.m trunk/octave-forge/main/control/inst/@lti/__lti_prune__.m trunk/octave-forge/main/control/inst/__frequency_range__.m Removed Paths: ------------- trunk/octave-forge/main/control/inst/@lti/__ltigroup__.m trunk/octave-forge/main/control/inst/@lti/__ltiprune__.m trunk/octave-forge/main/control/inst/__freqbounds__.m Added: trunk/octave-forge/main/control/inst/@lti/__lti_group__.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/__lti_group__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@lti/__lti_group__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -0,0 +1,47 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Block diagonal concatenation of two LTI models. +## This file is part of the Model Abstraction Layer. +## For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function retlti = __lti_group__ (lti1, lti2) + + retlti = lti (); + + retlti.inname = [lti1.inname; + lti2.inname]; + + retlti.outname = [lti1.outname; + lti2.outname]; + + if (lti1.tsam == lti2.tsam) + retlti.tsam = lti1.tsam; + elseif (lti1.tsam == -1) + retlti.tsam = lti2.tsam; + elseif (lti2.tsam == -1) + retlti.tsam = lti1.tsam; + else + error ("lti_group: systems must have identical sampling times"); + endif + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@lti/__lti_prune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/__lti_prune__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@lti/__lti_prune__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -0,0 +1,32 @@ +## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Submodel extraction and reordering for LTI objects. +## This file is part of the Model Abstraction Layer. +## For internal use only. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2009 +## Version: 0.1 + +function lti = __lti_prune__ (lti, out_idx, in_idx) + + lti.inname = lti.inname(in_idx); + lti.outname = lti.outname(out_idx); + +endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@lti/__ltigroup__.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/__ltigroup__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/@lti/__ltigroup__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -1,47 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Block diagonal concatenation of two LTI models. -## This file is part of the Model Abstraction Layer. -## For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function retlti = __ltigroup__ (lti1, lti2) - - retlti = lti (); - - retlti.inname = [lti1.inname; - lti2.inname]; - - retlti.outname = [lti1.outname; - lti2.outname]; - - if (lti1.tsam == lti2.tsam) - retlti.tsam = lti1.tsam; - elseif (lti1.tsam == -1) - retlti.tsam = lti2.tsam; - elseif (lti2.tsam == -1) - retlti.tsam = lti1.tsam; - else - error ("ltigroup: systems must have identical sampling times"); - endif - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/main/control/inst/@lti/__ltiprune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/__ltiprune__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/@lti/__ltiprune__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -1,32 +0,0 @@ -## Copyright (C) 2009 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 this program. If not, see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## Submodel extraction and reordering for LTI objects. -## This file is part of the Model Abstraction Layer. -## For internal use only. - -## Author: Lukas Reichlin <luk...@gm...> -## Created: September 2009 -## Version: 0.1 - -function lti = __ltiprune__ (lti, out_idx, in_idx) - - lti.inname = lti.inname(in_idx); - lti.outname = lti.outname(out_idx); - -endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/@ss/__sysgroup__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -36,7 +36,7 @@ retsys = ss (); - retsys.lti = __ltigroup__ (sys1.lti, sys2.lti); + retsys.lti = __lti_group__ (sys1.lti, sys2.lti); A1 = sys1.a; B1 = sys1.b; Modified: trunk/octave-forge/main/control/inst/@ss/__sysprune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__sysprune__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/@ss/__sysprune__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -26,7 +26,7 @@ function sys = __sysprune__ (sys, out_idx, in_idx, st_idx = ":") - sys.lti = __ltiprune__ (sys.lti, out_idx, in_idx); + sys.lti = __lti_prune__ (sys.lti, out_idx, in_idx); sys.a = sys.a(st_idx, st_idx); sys.b = sys.b(st_idx, in_idx); Modified: trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/@tf/__sysgroup__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -36,7 +36,7 @@ retsys = tf (); - retsys.lti = __ltigroup__ (sys1.lti, sys2.lti); + retsys.lti = __lti_group__ (sys1.lti, sys2.lti); [p1, m1] = size (sys1); [p2, m2] = size (sys2); Modified: trunk/octave-forge/main/control/inst/@tf/__sysprune__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sysprune__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/@tf/__sysprune__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -26,7 +26,7 @@ function sys = __sysprune__ (sys, out_idx, in_idx) - sys.lti = __ltiprune__ (sys.lti, out_idx, in_idx); + sys.lti = __lti_prune__ (sys.lti, out_idx, in_idx); sys.num = sys.num(out_idx, in_idx); sys.den = sys.den(out_idx, in_idx); Deleted: trunk/octave-forge/main/control/inst/__freqbounds__.m =================================================================== --- trunk/octave-forge/main/control/inst/__freqbounds__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/__freqbounds__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -1,122 +0,0 @@ -## Copyright (C) 1996, 2000, 2004, 2005, 2006, 2007 -## Auburn University. All rights reserved. -## -## -## This program 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. -## -## This program 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 this program; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {[@var{dec_min}, @var{dec_max}] =} __freqbounds__ (@var{sys}) -## 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{margin} (@command{bode}, @command{nyquist}) -## @end deftypefn - -## Adapted-By: Lukas Reichlin <luk...@gm...> -## Date: October 2009 -## Version: 0.1 - -function [dec_min, dec_max] = __freqbounds__ (sys, wbounds = "std") - - zer = zero (sys); - pol = pole (sys); - tsam = get (sys, "tsam"); - discrete = (tsam > 0); # static gains (tsam = -1) are continuous - - ## make sure zer, pol are row vectors - pol = reshape (pol, 1, []); - zer = reshape (zer, 1, []); - - ## check for natural frequencies away from omega = 0 - if (discrete) - ## The 2nd conditions prevents log(0) in the next log command - iiz = find (abs(zer-1) > norm(zer)*eps && abs(zer) > norm(zer)*eps); - iip = find (abs(pol-1) > norm(pol)*eps && abs(pol) > norm(pol)*eps); - - ## avoid dividing empty matrices, it would work but looks nasty - if (! isempty (iiz)) - czer = log (zer(iiz))/tsam; - else - czer = []; - endif - - if (! isempty (iip)) - cpol = log (pol(iip))/tsam; - else - cpol = []; - endif - else - ## continuous - iip = find (abs(pol) > norm(pol)*eps); - iiz = find (abs(zer) > norm(zer)*eps); - - if (! isempty (zer)) - czer = zer(iiz); - else - czer = []; - endif - if (! isempty (pol)) - cpol = pol(iip); - else - cpol = []; - endif - endif - - if (isempty (iip) && isempty (iiz)) - ## no poles/zeros away from omega = 0; pick defaults - dec_min = 0; # -1 - dec_max = 2; # 3 - else - dec_min = floor (log10 (min (abs ([cpol, czer])))); - dec_max = ceil (log10 (max (abs ([cpol, czer])))); - endif - - ## expand to show the entirety of the "interesting" portion of the plot - switch (wbounds) - case "std" # standard - if (dec_min == dec_max) - dec_min -= 2; - dec_max += 2; - else - dec_min--; - dec_max++; - endif - case "ext" # extended (for nyquist) - if (any (abs (pol) < sqrt (eps))) # look for integrators - ## dec_min -= 0.5; - dec_max += 2; - else - dec_min -= 2; - dec_max += 2; - endif - otherwise - error ("freqbounds: second argument invalid"); - endswitch - - ## run discrete frequency all the way to pi - if (discrete) - dec_max = log10 (pi/tsam); - endif - -endfunction Added: trunk/octave-forge/main/control/inst/__frequency_range__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_range__.m (rev 0) +++ trunk/octave-forge/main/control/inst/__frequency_range__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -0,0 +1,122 @@ +## Copyright (C) 1996, 2000, 2004, 2005, 2006, 2007 +## Auburn University. All rights reserved. +## +## +## This program 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. +## +## This program 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 this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{dec_min}, @var{dec_max}] =} __frequency_range__ (@var{sys}) +## 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{margin} (@command{bode}, @command{nyquist}) +## @end deftypefn + +## Adapted-By: Lukas Reichlin <luk...@gm...> +## Date: October 2009 +## Version: 0.1 + +function [dec_min, dec_max] = __frequency_range__ (sys, wbounds = "std") + + zer = zero (sys); + pol = pole (sys); + tsam = get (sys, "tsam"); + discrete = (tsam > 0); # static gains (tsam = -1) are continuous + + ## make sure zer, pol are row vectors + pol = reshape (pol, 1, []); + zer = reshape (zer, 1, []); + + ## check for natural frequencies away from omega = 0 + if (discrete) + ## The 2nd conditions prevents log(0) in the next log command + iiz = find (abs(zer-1) > norm(zer)*eps && abs(zer) > norm(zer)*eps); + iip = find (abs(pol-1) > norm(pol)*eps && abs(pol) > norm(pol)*eps); + + ## avoid dividing empty matrices, it would work but looks nasty + if (! isempty (iiz)) + czer = log (zer(iiz))/tsam; + else + czer = []; + endif + + if (! isempty (iip)) + cpol = log (pol(iip))/tsam; + else + cpol = []; + endif + else + ## continuous + iip = find (abs(pol) > norm(pol)*eps); + iiz = find (abs(zer) > norm(zer)*eps); + + if (! isempty (zer)) + czer = zer(iiz); + else + czer = []; + endif + if (! isempty (pol)) + cpol = pol(iip); + else + cpol = []; + endif + endif + + if (isempty (iip) && isempty (iiz)) + ## no poles/zeros away from omega = 0; pick defaults + dec_min = 0; # -1 + dec_max = 2; # 3 + else + dec_min = floor (log10 (min (abs ([cpol, czer])))); + dec_max = ceil (log10 (max (abs ([cpol, czer])))); + endif + + ## expand to show the entirety of the "interesting" portion of the plot + switch (wbounds) + case "std" # standard + if (dec_min == dec_max) + dec_min -= 2; + dec_max += 2; + else + dec_min--; + dec_max++; + endif + case "ext" # extended (for nyquist) + if (any (abs (pol) < sqrt (eps))) # look for integrators + ## dec_min -= 0.5; + dec_max += 2; + else + dec_min -= 2; + dec_max += 2; + endif + otherwise + error ("frequency_range: second argument invalid"); + endswitch + + ## run discrete frequency all the way to pi + if (discrete) + dec_max = log10 (pi/tsam); + endif + +endfunction Modified: trunk/octave-forge/main/control/inst/__frequency_response__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_response__.m 2010-09-14 23:59:19 UTC (rev 7721) +++ trunk/octave-forge/main/control/inst/__frequency_response__.m 2010-09-15 00:13:40 UTC (rev 7722) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## Return frequency response H and frequency vector w. -## If w is empty, it will be calculated by __freqbounds__ +## If w is empty, it will be calculated by __frequency_range__ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 @@ -41,7 +41,7 @@ ## find interesting frequency range w if not specified if (isempty (w)) ## begin plot at 10^dec_min, end plot at 10^dec_max [rad/s] - [dec_min, dec_max] = __freqbounds__ (sys, wbounds); + [dec_min, dec_max] = __frequency_range__ (sys, wbounds); w = logspace (dec_min, dec_max, 500); # [rad/s] endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |