From: <par...@us...> - 2012-02-29 20:09:12
|
Revision: 9723 http://octave.svn.sourceforge.net/octave/?rev=9723&view=rev Author: paramaniac Date: 2012-02-29 20:09:03 +0000 (Wed, 29 Feb 2012) Log Message: ----------- control: touch up example Modified Paths: -------------- trunk/octave-forge/main/control/inst/optiPID.m trunk/octave-forge/main/control/inst/optiPIDctrl.m trunk/octave-forge/main/control/inst/optiPIDfun.m Modified: trunk/octave-forge/main/control/inst/optiPID.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPID.m 2012-02-29 10:07:16 UTC (rev 9722) +++ trunk/octave-forge/main/control/inst/optiPID.m 2012-02-29 20:09:03 UTC (rev 9723) @@ -66,7 +66,6 @@ kp_opt = C_par_opt(1) Ti_opt = C_par_opt(2) Td_opt = C_par_opt(3) -tau_opt = Td_opt / 10 C_opt = optiPIDctrl (kp_opt, Ti_opt, Td_opt); Modified: trunk/octave-forge/main/control/inst/optiPIDctrl.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPIDctrl.m 2012-02-29 10:07:16 UTC (rev 9722) +++ trunk/octave-forge/main/control/inst/optiPIDctrl.m 2012-02-29 20:09:03 UTC (rev 9723) @@ -1,10 +1,18 @@ +% =============================================================================== +% optiPIDctrl Lukas Reichlin February 2012 +% =============================================================================== +% Return PID controller with roll-off for given parameters Kp, Ti and Td. +% =============================================================================== + function C = optiPIDctrl (Kp, Ti, Td) - tau = Td / 10; + tau = Td / 10; % roll-off num = Kp * [Ti*Td, Ti, 1]; den = conv ([Ti, 0], [tau^2, 2*tau, 1]); C = tf (num, den); -end \ No newline at end of file +end + +% =============================================================================== Modified: trunk/octave-forge/main/control/inst/optiPIDfun.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPIDfun.m 2012-02-29 10:07:16 UTC (rev 9722) +++ trunk/octave-forge/main/control/inst/optiPIDfun.m 2012-02-29 20:09:03 UTC (rev 9723) @@ -11,9 +11,14 @@ % Global Variables global P t dt mu_1 mu_2 mu_3 - % Function Argument -> PID Controller with Roll-Off - C = optiPIDctrl (num2cell (C_par){:}); + % Function Argument -> Controller Parameters + kp = C_par(1); + Ti = C_par(2); + Td = C_par(3); + % PID Controller with Roll-Off + C = optiPIDctrl (kp, Ti, Td); + % Open Loop L = P * C; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-03-05 21:38:41
|
Revision: 9750 http://octave.svn.sourceforge.net/octave/?rev=9750&view=rev Author: paramaniac Date: 2012-03-05 21:38:35 +0000 (Mon, 05 Mar 2012) Log Message: ----------- control: docfixes for order reduction functions Modified Paths: -------------- trunk/octave-forge/main/control/inst/bstmodred.m trunk/octave-forge/main/control/inst/btaconred.m trunk/octave-forge/main/control/inst/btamodred.m trunk/octave-forge/main/control/inst/cfconred.m trunk/octave-forge/main/control/inst/hnamodred.m trunk/octave-forge/main/control/inst/spaconred.m trunk/octave-forge/main/control/inst/spamodred.m Modified: trunk/octave-forge/main/control/inst/bstmodred.m =================================================================== --- trunk/octave-forge/main/control/inst/bstmodred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/bstmodred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -152,35 +152,16 @@ ## performed on system @var{G} prior to order reduction. ## Default value is true if @code{G.scaled == false} and ## false if @code{G.scaled == true}. +## Note that 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. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. ## @end table ## ## -## For the H-infinity norm, the best approximation problem is -## unsolved so far. Nevertheless, balanced truncation and related -## methods can be used to obtain good approximations using this measure. -## -## Available approximation methods are the accuracy-enhancing square-root (SR) -## or the balancing-free square-root (BFSR) versions of -## the Balance & Truncate (BTA) or Singular Perturbation Approximation (SPA) -## model reduction methods for the ALPHA-stable part of the system. -## -## Unstable models are handled by separating the stable and unstable -## parts additively, applying the model reduction only to the stable -## part and by joining the reduced stable with the original unstable part. -## The order of the reduced system can be selected by the user or -## can be determined automatically on the basis of the computed -## Hankel singular values. -## -## For MIMO models, proper scaling of input-output channels is of -## utmost importance. This can @strong{not} be done by the equilibration -## option or the @command{prescale} command because these perform state -## transformations only. While enhancing numerics, state transformations -## have no influence on the input-output behaviour and the magnitude of -## the corresponding signals. Since the algorithm calculates the -## H-infinity norm of these signals, 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}. -## ## BST is often suitable to perform model reduction in order to obtain ## low order design models for controller synthesis. ## Modified: trunk/octave-forge/main/control/inst/btaconred.m =================================================================== --- trunk/octave-forge/main/control/inst/btaconred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/btaconred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -205,6 +205,13 @@ ## performed on @var{G} and @var{K} prior to order reduction. ## Default value is false if both @code{G.scaled == true, K.scaled == true} ## and true otherwise. +## Note that 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. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. ## @end table ## ## @strong{Algorithm}@* Modified: trunk/octave-forge/main/control/inst/btamodred.m =================================================================== --- trunk/octave-forge/main/control/inst/btamodred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/btamodred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -183,22 +183,16 @@ ## 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 -## -## For @acronym{MIMO} models, proper scaling of both inputs and outputs +## Note that 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}. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. +## @end table ## +## ## Approximation Properties: ## @itemize @bullet ## @item Modified: trunk/octave-forge/main/control/inst/cfconred.m =================================================================== --- trunk/octave-forge/main/control/inst/cfconred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/cfconred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -119,6 +119,13 @@ ## performed on system @var{G} prior to order reduction. ## Default value is true if @code{G.scaled == false} and ## false if @code{G.scaled == true}. +## Note that 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. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. ## @end table ## ## @strong{Algorithm}@* Modified: trunk/octave-forge/main/control/inst/hnamodred.m =================================================================== --- trunk/octave-forge/main/control/inst/hnamodred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/hnamodred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -245,13 +245,16 @@ ## performed on system @var{G} prior to order reduction. ## Default value is true if @code{G.scaled == false} and ## false if @code{G.scaled == true}. +## Note that 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. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. ## @end table ## ## -## UNSTABLE (from bstmodred) -## -## MIMO (from bstmodred) -## ## Approximation Properties: ## @itemize @bullet ## @item Modified: trunk/octave-forge/main/control/inst/spaconred.m =================================================================== --- trunk/octave-forge/main/control/inst/spaconred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/spaconred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -205,6 +205,13 @@ ## performed on @var{G} and @var{K} prior to order reduction. ## Default value is false if both @code{G.scaled == true, K.scaled == true} ## and true otherwise. +## Note that 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. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. ## @end table ## ## @strong{Algorithm}@* Modified: trunk/octave-forge/main/control/inst/spamodred.m =================================================================== --- trunk/octave-forge/main/control/inst/spamodred.m 2012-03-05 18:46:32 UTC (rev 9749) +++ trunk/octave-forge/main/control/inst/spamodred.m 2012-03-05 21:38:35 UTC (rev 9750) @@ -182,6 +182,13 @@ ## performed on system @var{G} prior to order reduction. ## Default value is true if @code{G.scaled == false} and ## false if @code{G.scaled == true}. +## Note that 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. +## Furthermore, signals should not be scaled simply to a certain range. +## For all inputs (or outputs), a certain change should be of the same +## importance for the model. ## @end table ## ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-03-06 15:52:19
|
Revision: 9755 http://octave.svn.sourceforge.net/octave/?rev=9755&view=rev Author: paramaniac Date: 2012-03-06 15:52:10 +0000 (Tue, 06 Mar 2012) Log Message: ----------- control: fix bug with scaling option Modified Paths: -------------- trunk/octave-forge/main/control/inst/cfconred.m trunk/octave-forge/main/control/inst/fwcfconred.m Modified: trunk/octave-forge/main/control/inst/cfconred.m =================================================================== --- trunk/octave-forge/main/control/inst/cfconred.m 2012-03-06 13:49:13 UTC (rev 9754) +++ trunk/octave-forge/main/control/inst/cfconred.m 2012-03-06 15:52:10 UTC (rev 9755) @@ -197,7 +197,7 @@ tol2 = 0.0; jobcf = 0; jobmr = 2; # balancing-free BTA - equil = scaled && scaledc; + equil = scaled # equil: 0 means "S", 1 means "N" ordsel = 1; ncr = 0; negfb = true; # A-BK, A-LC Hurwitz Modified: trunk/octave-forge/main/control/inst/fwcfconred.m =================================================================== --- trunk/octave-forge/main/control/inst/fwcfconred.m 2012-03-06 13:49:13 UTC (rev 9754) +++ trunk/octave-forge/main/control/inst/fwcfconred.m 2012-03-06 15:52:10 UTC (rev 9755) @@ -151,7 +151,7 @@ error ("fwcfconred: keys and values must come in pairs"); endif - [a, b, c, d, tsam, scaled] = ssdata (G); + [a, b, c, d, tsam] = ssdata (G); [p, m] = size (G); n = rows (a); [mf, nf] = size (F); @@ -173,7 +173,6 @@ tol1 = 0.0; jobcf = 1; jobmr = 1; # balancing-free BTA - equil = scaled && scaledc; ordsel = 1; ncr = 0; negfb = true; # A-BK, A-LC Hurwitz This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-04-22 08:37:30
|
Revision: 10309 http://octave.svn.sourceforge.net/octave/?rev=10309&view=rev Author: paramaniac Date: 2012-04-22 08:37:24 +0000 (Sun, 22 Apr 2012) Log Message: ----------- control: style fixes (use strncmpi) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/frdata.m trunk/octave-forge/main/control/inst/@lti/tfdata.m trunk/octave-forge/main/control/inst/@lti/zpkdata.m trunk/octave-forge/main/control/inst/gram.m Modified: trunk/octave-forge/main/control/inst/@lti/frdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/frdata.m 2012-04-22 08:22:39 UTC (rev 10308) +++ trunk/octave-forge/main/control/inst/@lti/frdata.m 2012-04-22 08:37:24 UTC (rev 10309) @@ -1,4 +1,4 @@ -## Copyright (C) 2010, 2011 Lukas F. Reichlin +## Copyright (C) 2010, 2011, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2010 -## Version: 0.2 +## Version: 0.3 function [H, w, tsam] = frdata (sys, rtype = "array") @@ -60,7 +60,7 @@ tsam = sys.tsam; - if (lower (rtype(1)) == "v" && issiso (sys)) + if (strncmpi (rtype, "v", 1) && issiso (sys)) H = reshape (H, [], 1); endif Modified: trunk/octave-forge/main/control/inst/@lti/tfdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/tfdata.m 2012-04-22 08:22:39 UTC (rev 10308) +++ trunk/octave-forge/main/control/inst/@lti/tfdata.m 2012-04-22 08:37:24 UTC (rev 10309) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -54,7 +54,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.4 +## Version: 0.5 function [num, den, tsam] = tfdata (sys, rtype = "cell") @@ -66,12 +66,12 @@ tsam = sys.tsam; - if (lower (rtype(1)) != "t") # != tfpoly + if (! strncmpi (rtype, "t", 1)) # != tfpoly num = cellfun (@get, num, "uniformoutput", false); den = cellfun (@get, den, "uniformoutput", false); endif - if (lower (rtype(1)) == "v" && issiso (sys)) # == vector + if (strncmpi (rtype, "v", 1) && issiso (sys)) # == vector num = num{1}; den = den{1}; endif Modified: trunk/octave-forge/main/control/inst/@lti/zpkdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/zpkdata.m 2012-04-22 08:22:39 UTC (rev 10308) +++ trunk/octave-forge/main/control/inst/@lti/zpkdata.m 2012-04-22 08:37:24 UTC (rev 10309) @@ -58,7 +58,7 @@ p = cellfun (@roots, den, "uniformoutput", false); k = cellfun (@(n,d) n(1)/d(1), num, den); - if (lower (rtype(1)) == "v" && issiso (sys)) + if (strncmpi (rtype, "v", 1) && issiso (sys)) z = z{1}; p = p{1}; endif Modified: trunk/octave-forge/main/control/inst/gram.m =================================================================== --- trunk/octave-forge/main/control/inst/gram.m 2012-04-22 08:22:39 UTC (rev 10308) +++ trunk/octave-forge/main/control/inst/gram.m 2012-04-22 08:37:24 UTC (rev 10309) @@ -33,7 +33,7 @@ ## Adapted-By: Lukas Reichlin <luk...@gm...> ## Date: October 2009 -## Version: 0.1 +## Version: 0.2 function W = gram (argin1, argin2) @@ -43,7 +43,6 @@ if (ischar (argin2)) # the function was called as "gram (sys, mode)" sys = argin1; - argin2 = lower (argin2); if (! isa (sys, "lti")) error ("gram: first argument must be an LTI model"); @@ -51,10 +50,10 @@ [a, b, c] = ssdata (sys); - if (strcmp (argin2, "o")) + if (strncmpi (argin2, "o", 1)) a = a.'; b = c.'; - elseif (! strcmp (argin2, "c")) + elseif (! strncmpi (argin2, "c", 1)) print_usage (); endif else # the function was called as "gram (a, b)" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-06 19:37:01
|
Revision: 10368 http://octave.svn.sourceforge.net/octave/?rev=10368&view=rev Author: paramaniac Date: 2012-05-06 19:36:54 +0000 (Sun, 06 May 2012) Log Message: ----------- control: support transfer function variable z^-1 Modified Paths: -------------- trunk/octave-forge/main/control/inst/@tf/__set__.m trunk/octave-forge/main/control/inst/@tf/__sys_group__.m trunk/octave-forge/main/control/inst/@tf/display.m trunk/octave-forge/main/control/inst/@tf/tf.m trunk/octave-forge/main/control/inst/filt.m Added Paths: ----------- trunk/octave-forge/main/control/inst/tfpoly2str.m Modified: trunk/octave-forge/main/control/inst/@tf/__set__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__set__.m 2012-05-06 15:53:35 UTC (rev 10367) +++ trunk/octave-forge/main/control/inst/@tf/__set__.m 2012-05-06 19:36:54 UTC (rev 10368) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -20,7 +20,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function sys = __set__ (sys, prop, val) @@ -42,6 +42,13 @@ error ("tf: set: invalid transfer function variable"); endif + case "inv" + if (islogical (val)) + sys.inv = logical (val); + else + error ("tf: set: property 'inv' must be a logical"); + endif + otherwise error ("tf: set: invalid property name"); Modified: trunk/octave-forge/main/control/inst/@tf/__sys_group__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys_group__.m 2012-05-06 15:53:35 UTC (rev 10367) +++ trunk/octave-forge/main/control/inst/@tf/__sys_group__.m 2012-05-06 19:36:54 UTC (rev 10368) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -22,7 +22,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.1 +## Version: 0.2 function retsys = __sys_group__ (sys1, sys2) @@ -61,4 +61,8 @@ retsys.tfvar = sys1.tfvar; endif -endfunction \ No newline at end of file + if (sys1.inv && sys2.inv) + retsys.inv = true; + endif + +endfunction Modified: trunk/octave-forge/main/control/inst/@tf/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/display.m 2012-05-06 15:53:35 UTC (rev 10367) +++ trunk/octave-forge/main/control/inst/@tf/display.m 2012-05-06 19:36:54 UTC (rev 10368) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -20,7 +20,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.3 +## Version: 0.4 function display (sys) @@ -31,12 +31,19 @@ [outname, p] = __labels__ (outname, "y"); disp (""); + + if (sys.inv) + [num, den] = filtdata (sys); + else + num = sys.num; + den = sys.den; + endif for nu = 1 : m disp (["Transfer function '", sysname, "' from input '", inname{nu}, "' to output ..."]); disp (""); for ny = 1 : p - __disp_frac__ (sys.num{ny, nu}, sys.den{ny, nu}, sys.tfvar, outname{ny}); + __disp_frac__ (num{ny, nu}, den{ny, nu}, sys.tfvar, outname{ny}); endfor endfor @@ -56,10 +63,12 @@ function __disp_frac__ (num, den, tfvar, name) MAX_LEN = 12; # max length of output name + + tfp = isa (num, "tfpoly"); - if (num == 0) + if (tfp && num == 0) str = [" ", name, ": 0"]; - elseif (den == 1) + elseif (tfp && den == 1) str = [" ", name, ": "]; numstr = tfpoly2str (num, tfvar); str = [str, numstr]; Modified: trunk/octave-forge/main/control/inst/@tf/tf.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/tf.m 2012-05-06 15:53:35 UTC (rev 10367) +++ trunk/octave-forge/main/control/inst/@tf/tf.m 2012-05-06 19:36:54 UTC (rev 10368) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -119,7 +119,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.2.1 +## Version: 0.3 function sys = tf (num = {}, den = {}, varargin) @@ -196,7 +196,8 @@ tfdata = struct ("num", {num}, "den", {den}, - "tfvar", tfvar); # struct for tf-specific data + "tfvar", tfvar, + "inv", false); # struct for tf-specific data ltisys = lti (p, m, tsam); # parent class for general lti data Modified: trunk/octave-forge/main/control/inst/filt.m =================================================================== --- trunk/octave-forge/main/control/inst/filt.m 2012-05-06 15:53:35 UTC (rev 10367) +++ trunk/octave-forge/main/control/inst/filt.m 2012-05-06 19:36:54 UTC (rev 10368) @@ -116,7 +116,7 @@ ## use standard tf constructor ## sys is stored and displayed in standard z form, not z^-1 - sys = tf (num, den, tsam, varargin{:}); + sys = tf (num, den, tsam, "inv", true, varargin{:}); endswitch endfunction Added: trunk/octave-forge/main/control/inst/tfpoly2str.m =================================================================== --- trunk/octave-forge/main/control/inst/tfpoly2str.m (rev 0) +++ trunk/octave-forge/main/control/inst/tfpoly2str.m 2012-05-06 19:36:54 UTC (rev 10368) @@ -0,0 +1,89 @@ +## 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{str} =} tfpoly2str (@var{p}) +## @deftypefnx {Function File} {@var{str} =} tfpoly2str (@var{p}, @var{tfvar}) +## Return the string of a polynomial with string @var{tfvar} as variable. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2012 +## Version: 0.1 + +function str = tfpoly2str (p, tfvar = "x") + + str = ""; + + lp = numel (p); + + if (lp > 0) + ## first element (lowest order 0) + a = p(1); + + if (a < 0) + cs = "-"; + else + cs = ""; + endif + + str = [cs, num2str(abs (a), 4)]; + + if (lp > 1) + ## remaining elements of higher order + for k = 2 : lp + a = p(k); + + if (a != 0) + if (a < 0) + cs = " - "; + else + cs = " + "; + endif + + if (abs (a) == 1) + str = [str, cs, __variable__(tfvar, k-1)]; + else + str = [str, cs, __coefficient__(a), " ", __variable__(tfvar, k-1)]; + endif + endif + endfor + + endif + endif + +endfunction + + +function str = __coefficient__ (a) + + b = abs (a); + + if (b == 1) + str = ""; + else + str = num2str (b, 4); + endif + +endfunction + + +function str = __variable__ (tfvar, n) + + str = [tfvar, "^-", num2str(n)]; + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-06 20:17:49
|
Revision: 10369 http://octave.svn.sourceforge.net/octave/?rev=10369&view=rev Author: paramaniac Date: 2012-05-06 20:17:43 +0000 (Sun, 06 May 2012) Log Message: ----------- control: fix display of transfer function variable z^-1 Modified Paths: -------------- trunk/octave-forge/main/control/inst/filt.m trunk/octave-forge/main/control/inst/tfpoly2str.m Modified: trunk/octave-forge/main/control/inst/filt.m =================================================================== --- trunk/octave-forge/main/control/inst/filt.m 2012-05-06 19:36:54 UTC (rev 10368) +++ trunk/octave-forge/main/control/inst/filt.m 2012-05-06 20:17:43 UTC (rev 10369) @@ -57,9 +57,9 @@ ## ## Transfer function 'H' from input 'u1' to output ... ## -## 3 z -## y1: ------------- -## z^2 + 4 z + 2 +## 3 z^-1 +## y1: ------------------- +## 1 + 4 z^-1 + 2 z^-2 ## ## Sampling time: unspecified ## Discrete-time model. Modified: trunk/octave-forge/main/control/inst/tfpoly2str.m =================================================================== --- trunk/octave-forge/main/control/inst/tfpoly2str.m 2012-05-06 19:36:54 UTC (rev 10368) +++ trunk/octave-forge/main/control/inst/tfpoly2str.m 2012-05-06 20:17:43 UTC (rev 10369) @@ -27,13 +27,21 @@ function str = tfpoly2str (p, tfvar = "x") + ## TODO: simplify this ugly code + str = ""; lp = numel (p); - if (lp > 0) - ## first element (lowest order 0) - a = p(1); + if (lp > 0) # first element (lowest order) + idx = find (p); # first non-zero element + if (isempty (idx)) + str = "0"; + return; + else + idx = idx(1); + endif + a = p(idx); if (a < 0) cs = "-"; @@ -41,11 +49,18 @@ cs = ""; endif - str = [cs, num2str(abs (a), 4)]; + if (idx == 1) + str = [cs, num2str(abs (a), 4)]; + else + if (abs (a) == 1) + str = [cs, __variable__(tfvar, idx-1)]; + else + str = [cs, __coefficient__(a), " ", __variable__(tfvar, idx-1)]; + endif + endif - if (lp > 1) - ## remaining elements of higher order - for k = 2 : lp + if (lp > idx) # remaining elements of higher order + for k = idx+1 : lp a = p(k); if (a != 0) @@ -84,6 +99,6 @@ function str = __variable__ (tfvar, n) - str = [tfvar, "^-", num2str(n)]; + str = [tfvar, "^-", num2str(n)]; endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-05-07 04:39:48
|
Revision: 10372 http://octave.svn.sourceforge.net/octave/?rev=10372&view=rev Author: paramaniac Date: 2012-05-07 04:39:42 +0000 (Mon, 07 May 2012) Log Message: ----------- control: handle special case num=0 or den=1 when displaying z^-1 Modified Paths: -------------- trunk/octave-forge/main/control/inst/@tf/display.m trunk/octave-forge/main/control/inst/filt.m Modified: trunk/octave-forge/main/control/inst/@tf/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/display.m 2012-05-07 03:27:54 UTC (rev 10371) +++ trunk/octave-forge/main/control/inst/@tf/display.m 2012-05-07 04:39:42 UTC (rev 10372) @@ -66,9 +66,11 @@ tfp = isa (num, "tfpoly"); - if (tfp && num == 0) + if (num == tfpoly (0)) str = [" ", name, ": 0"]; - elseif (tfp && den == 1) + elseif ((tfp && den == 1) || (! tfp && isequal (den, 1))) + ## elseif (den == tfpoly (1)) doesn't work because it + ## would mistakingly accept non-tfpoly denominators like [0, 1] str = [" ", name, ": "]; numstr = tfpoly2str (num, tfvar); str = [str, numstr]; Modified: trunk/octave-forge/main/control/inst/filt.m =================================================================== --- trunk/octave-forge/main/control/inst/filt.m 2012-05-07 03:27:54 UTC (rev 10371) +++ trunk/octave-forge/main/control/inst/filt.m 2012-05-07 04:39:42 UTC (rev 10372) @@ -78,11 +78,13 @@ switch (nargin) case 0 # filt () sys = tf (); + ## sys.inv = true; return; case 1 # filt (sys), filt (matrix) if (isa (num, "lti") || is_real_matrix (num)) sys = tf (num); + ## sys.inv = true; # would be a problem for continuous-time LTI models return; else print_usage (); @@ -115,7 +117,9 @@ den = cellfun (@postpad, den, lmax, "uniformoutput", false); ## use standard tf constructor - ## sys is stored and displayed in standard z form, not z^-1 + ## sys is stored in standard z form, not z^-1 + ## so we can mix it with regular transfer function models + ## property "inv", true displays sys in z^-1 form sys = tf (num, den, tsam, "inv", true, varargin{:}); endswitch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-09 09:02:46
|
Revision: 10609 http://octave.svn.sourceforge.net/octave/?rev=10609&view=rev Author: paramaniac Date: 2012-06-09 09:02:40 +0000 (Sat, 09 Jun 2012) Log Message: ----------- control: relocate test Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/subsref.m trunk/octave-forge/main/control/inst/ltimodels.m trunk/octave-forge/main/control/inst/test_control.m Modified: trunk/octave-forge/main/control/inst/@lti/subsref.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/subsref.m 2012-06-09 07:37:08 UTC (rev 10608) +++ trunk/octave-forge/main/control/inst/@lti/subsref.m 2012-06-09 09:02:40 UTC (rev 10609) @@ -21,7 +21,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.3 +## Version: 0.4 function a = subsref (a, s) @@ -50,3 +50,11 @@ a = subsref (a, s(2:end)); endfunction + + +## lti: subsref +%!shared a +%! s = tf ("s"); +%! G = (s+1)*s*5/(s+1)/(s^2+s+1); +%! a = G(1,1).num{1,1}(1); +%!assert (a, 5, 1e-4); Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2012-06-09 07:37:08 UTC (rev 10608) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2012-06-09 09:02:40 UTC (rev 10609) @@ -97,15 +97,7 @@ %!assert (isdt (ltisys)); -## lti: subsref -%!shared a -%! s = tf ("s"); -%! G = (s+1)*s*5/(s+1)/(s^2+s+1); -%! a = G(1,1).num{1,1}(1); -%!assert (a, 5, 1e-4); - - ## ============================================================================== ## TF Tests ## ============================================================================== Modified: trunk/octave-forge/main/control/inst/test_control.m =================================================================== --- trunk/octave-forge/main/control/inst/test_control.m 2012-06-09 07:37:08 UTC (rev 10608) +++ trunk/octave-forge/main/control/inst/test_control.m 2012-06-09 09:02:40 UTC (rev 10609) @@ -54,6 +54,7 @@ test @lti/plus test @lti/prescale test @lti/sminreal +test @lti/subsref test @lti/zero ## robust control This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-09 09:29:40
|
Revision: 10610 http://octave.svn.sourceforge.net/octave/?rev=10610&view=rev Author: paramaniac Date: 2012-06-09 09:29:34 +0000 (Sat, 09 Jun 2012) Log Message: ----------- control: remove infinite poles, rename variable Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/isstable.m trunk/octave-forge/main/control/inst/__is_stable__.m trunk/octave-forge/main/control/inst/isstabilizable.m Modified: trunk/octave-forge/main/control/inst/@lti/isstable.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isstable.m 2012-06-09 09:02:40 UTC (rev 10609) +++ trunk/octave-forge/main/control/inst/@lti/isstable.m 2012-06-09 09:29:34 UTC (rev 10610) @@ -31,9 +31,9 @@ print_usage (); endif - eigw = pole (sys); + pol = pole (sys); ct = isct (sys); - bool = __is_stable__ (eigw, ct, tol); + bool = __is_stable__ (pol, ct, tol); -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/__is_stable__.m =================================================================== --- trunk/octave-forge/main/control/inst/__is_stable__.m 2012-06-09 09:02:40 UTC (rev 10609) +++ trunk/octave-forge/main/control/inst/__is_stable__.m 2012-06-09 09:29:34 UTC (rev 10610) @@ -22,12 +22,12 @@ ## Created: December 2010 ## Version: 0.1 -function bool = __is_stable__ (eigw, ct = true, tol = 0) +function bool = __is_stable__ (pol, ct = true, tol = 0) if (ct) # continuous-time - bool = all (real (eigw) < -tol*(1 + abs (eigw))); + bool = all (real (pol) < -tol*(1 + abs (pol))); else # discrete-time - bool = all (abs (eigw) < 1 - tol); + bool = all (abs (pol) < 1 - tol); endif -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/isstabilizable.m =================================================================== --- trunk/octave-forge/main/control/inst/isstabilizable.m 2012-06-09 09:02:40 UTC (rev 10609) +++ trunk/octave-forge/main/control/inst/isstabilizable.m 2012-06-09 09:29:34 UTC (rev 10610) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -73,7 +73,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.3.1 +## Version: 0.4 function bool = isstabilizable (a, b = [], e = [], tol = [], dflg = 0) @@ -109,7 +109,7 @@ auncont = ac(uncont_idx, uncont_idx); ## calculate poles of uncontrollable part - eigw = eig (auncont); + pol = eig (auncont); else ## controllability staircase form - output matrix c has no influence [ac, ec, ~, ~, ~, ~, ncont] = sltg01hd (a, e, b, zeros (1, columns (a)), tol); @@ -120,10 +120,15 @@ euncont = ec(uncont_idx, uncont_idx); ## calculate poles of uncontrollable part - eigw = eig (auncont, euncont); + pol = eig (auncont, euncont); + + ## remove infinite poles + tolinf = norm ([auncont, euncont], 2); + idx = find (abs (pol) < tolinf/eps); + pol = pol(idx); endif ## check whether uncontrollable poles are stable - bool = __is_stable__ (eigw, ! dflg, tol); + bool = __is_stable__ (pol, ! dflg, tol); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-20 05:43:02
|
Revision: 10642 http://octave.svn.sourceforge.net/octave/?rev=10642&view=rev Author: paramaniac Date: 2012-06-20 05:42:56 +0000 (Wed, 20 Jun 2012) Log Message: ----------- control: specify matrix dimensions in help texts Modified Paths: -------------- trunk/octave-forge/main/control/inst/dlqr.m trunk/octave-forge/main/control/inst/lqr.m Modified: trunk/octave-forge/main/control/inst/dlqr.m =================================================================== --- trunk/octave-forge/main/control/inst/dlqr.m 2012-06-19 20:23:47 UTC (rev 10641) +++ trunk/octave-forge/main/control/inst/dlqr.m 2012-06-20 05:42:56 UTC (rev 10642) @@ -27,29 +27,29 @@ ## @strong{Inputs} ## @table @var ## @item sys -## Continuous or discrete-time LTI model. +## Continuous or discrete-time LTI model (p-by-m, n states). ## @item a -## State transition matrix of discrete-time system. +## State transition matrix of discrete-time system (n-by-n). ## @item b -## Input matrix of discrete-time system. +## Input matrix of discrete-time system (n-by-m). ## @item q -## State weighting matrix. +## State weighting matrix (n-by-n). ## @item r -## Input weighting matrix. +## Input weighting matrix (m-by-m). ## @item s -## Optional cross term matrix. If @var{s} is not specified, a zero matrix is assumed. +## Optional cross term matrix (n-by-m). If @var{s} is not specified, a zero matrix is assumed. ## @item e -## Optional descriptor matrix. If @var{e} is not specified, an identity matrix is assumed. +## Optional descriptor matrix (n-by-n). If @var{e} is not specified, an identity matrix is assumed. ## @end table ## ## @strong{Outputs} ## @table @var ## @item g -## State feedback matrix. +## State feedback matrix (m-by-n). ## @item x -## Unique stabilizing solution of the discrete-time Riccati equation. +## Unique stabilizing solution of the discrete-time Riccati equation (n-by-n). ## @item l -## Closed-loop poles. +## Closed-loop poles (n-by-1). ## @end table ## ## @strong{Equations} Modified: trunk/octave-forge/main/control/inst/lqr.m =================================================================== --- trunk/octave-forge/main/control/inst/lqr.m 2012-06-19 20:23:47 UTC (rev 10641) +++ trunk/octave-forge/main/control/inst/lqr.m 2012-06-20 05:42:56 UTC (rev 10642) @@ -27,29 +27,29 @@ ## @strong{Inputs} ## @table @var ## @item sys -## Continuous or discrete-time LTI model. +## Continuous or discrete-time LTI model (p-by-m, n states). ## @item a -## State transition matrix of continuous-time system. +## State transition matrix of continuous-time system (n-by-n). ## @item b -## Input matrix of continuous-time system. +## Input matrix of continuous-time system (n-by-m). ## @item q -## State weighting matrix. +## State weighting matrix (n-by-n). ## @item r -## Input weighting matrix. +## Input weighting matrix (m-by-m). ## @item s -## Optional cross term matrix. If @var{s} is not specified, a zero matrix is assumed. +## Optional cross term matrix (n-by-m). If @var{s} is not specified, a zero matrix is assumed. ## @item e -## Optional descriptor matrix. If @var{e} is not specified, an identity matrix is assumed. +## Optional descriptor matrix (n-by-n). If @var{e} is not specified, an identity matrix is assumed. ## @end table ## ## @strong{Outputs} ## @table @var ## @item g -## State feedback matrix. +## State feedback matrix (m-by-n). ## @item x -## Unique stabilizing solution of the continuous-time Riccati equation. +## Unique stabilizing solution of the continuous-time Riccati equation (n-by-n). ## @item l -## Closed-loop poles. +## Closed-loop poles (n-by-1). ## @end table ## ## @strong{Equations} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-21 11:26:33
|
Revision: 10654 http://octave.svn.sourceforge.net/octave/?rev=10654&view=rev Author: paramaniac Date: 2012-06-21 11:26:26 +0000 (Thu, 21 Jun 2012) Log Message: ----------- control: doc fixes Modified Paths: -------------- trunk/octave-forge/main/control/inst/dlqe.m trunk/octave-forge/main/control/inst/lqe.m Modified: trunk/octave-forge/main/control/inst/dlqe.m =================================================================== --- trunk/octave-forge/main/control/inst/dlqe.m 2012-06-21 09:21:55 UTC (rev 10653) +++ trunk/octave-forge/main/control/inst/dlqe.m 2012-06-21 11:26:26 UTC (rev 10654) @@ -17,10 +17,10 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) -## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} lqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) +## @deftypefn {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} dlqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} dlqe (@var{a}, @var{g}, @var{c}, @var{q}, @var{r}, @var{s}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} dlqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}) +## @deftypefnx {Function File} {[@var{l}, @var{p}, @var{z}, @var{e}] =} dlqe (@var{a}, @var{[]}, @var{c}, @var{q}, @var{r}, @var{s}) ## Kalman filter for discrete-time systems. ## ## @example @@ -33,8 +33,6 @@ ## ## @strong{Inputs} ## @table @var -## @item sys -## Continuous or discrete-time LTI model (p-by-m, n states). ## @item a ## State transition matrix of discrete-time system (n-by-n). ## @item g @@ -46,7 +44,8 @@ ## @item r ## Measurement noise covariance matrix (p-by-p). ## @item s -## Optional cross term covariance matrix (g-by-p), s = cov(w,v) If @var{s} is not specified, a zero matrix is assumed. +## Optional cross term covariance matrix (g-by-p), s = cov(w,v). +## If @var{s} is not specified, a zero matrix is assumed. ## @end table ## ## @strong{Outputs} @@ -55,6 +54,7 @@ ## Kalman filter gain matrix (n-by-p). ## @item p ## Unique stabilizing solution of the discrete-time Riccati equation (n-by-n). +## Symmetric matrix. ## @item z ## Error covariance (n-by-n), cov(x(k|k)-x) ## @item e Modified: trunk/octave-forge/main/control/inst/lqe.m =================================================================== --- trunk/octave-forge/main/control/inst/lqe.m 2012-06-21 09:21:55 UTC (rev 10653) +++ trunk/octave-forge/main/control/inst/lqe.m 2012-06-21 11:26:26 UTC (rev 10654) @@ -49,7 +49,8 @@ ## @item r ## Measurement noise covariance matrix (p-by-p). ## @item s -## Optional cross term covariance matrix (g-by-p), s = cov(w,v) If @var{s} is not specified, a zero matrix is assumed. +## Optional cross term covariance matrix (g-by-p), s = cov(w,v). +## If @var{s} is not specified, a zero matrix is assumed. ## @end table ## ## @strong{Outputs} @@ -58,6 +59,8 @@ ## Kalman filter gain matrix (n-by-p). ## @item p ## Unique stabilizing solution of the continuous-time Riccati equation (n-by-n). +## Symmetric matrix. If @var{sys} is a discrete-time model, the solution of the +## corresponding discrete-time Riccati equation is returned. ## @item e ## Closed-loop poles (n-by-1). ## @end table @@ -102,5 +105,8 @@ endif l = l.'; + + ## NOTE: for discrete-time sys, the solution L' from DARE + ## is different to L from DLQE (a, s) endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-23 07:34:22
|
Revision: 10674 http://octave.svn.sourceforge.net/octave/?rev=10674&view=rev Author: paramaniac Date: 2012-06-23 07:34:15 +0000 (Sat, 23 Jun 2012) Log Message: ----------- control: minor doc enhancements Modified Paths: -------------- trunk/octave-forge/main/control/inst/covar.m trunk/octave-forge/main/control/inst/dlqe.m trunk/octave-forge/main/control/inst/isctrb.m trunk/octave-forge/main/control/inst/isdetectable.m trunk/octave-forge/main/control/inst/isobsv.m trunk/octave-forge/main/control/inst/isstabilizable.m trunk/octave-forge/main/control/inst/lqe.m Modified: trunk/octave-forge/main/control/inst/covar.m =================================================================== --- trunk/octave-forge/main/control/inst/covar.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/covar.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -24,7 +24,7 @@ ## @item sys ## LTI model. ## @item w -## Intensity of white noise inputs which drive @var{sys}. +## Intensity of Gaussian white noise inputs which drive @var{sys}. ## @end table ## ## @strong{Outputs} Modified: trunk/octave-forge/main/control/inst/dlqe.m =================================================================== --- trunk/octave-forge/main/control/inst/dlqe.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/dlqe.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -37,6 +37,7 @@ ## State transition matrix of discrete-time system (n-by-n). ## @item g ## Process noise matrix of discrete-time system (n-by-g). +## If @var{g} is empty @code{[]}, an identity matrix is assumed. ## @item c ## Measurement matrix of discrete-time system (p-by-n). ## @item q @@ -45,7 +46,7 @@ ## Measurement noise covariance matrix (p-by-p). ## @item s ## Optional cross term covariance matrix (g-by-p), s = cov(w,v). -## If @var{s} is not specified, a zero matrix is assumed. +## If @var{s} is empty @code{[]} or not specified, a zero matrix is assumed. ## @end table ## ## @strong{Outputs} Modified: trunk/octave-forge/main/control/inst/isctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/isctrb.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/isctrb.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -36,6 +36,7 @@ ## Input matrix. ## @item e ## Descriptor matrix. +## If @var{e} is empty @code{[]} or not specified, an identity matrix is assumed. ## @item tol ## Optional roundoff parameter. Default value is 0. ## @end table Modified: trunk/octave-forge/main/control/inst/isdetectable.m =================================================================== --- trunk/octave-forge/main/control/inst/isdetectable.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/isdetectable.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -39,6 +39,7 @@ ## Measurement matrix. ## @item e ## Descriptor matrix. +## If @var{e} is empty @code{[]} or not specified, an identity matrix is assumed. ## @item tol ## Optional tolerance for stability. Default value is 0. ## @item dflg = 0 Modified: trunk/octave-forge/main/control/inst/isobsv.m =================================================================== --- trunk/octave-forge/main/control/inst/isobsv.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/isobsv.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -36,6 +36,7 @@ ## Measurement matrix. ## @item e ## Descriptor matrix. +## If @var{e} is empty @code{[]} or not specified, an identity matrix is assumed. ## @item tol ## Optional roundoff parameter. Default value is 0. ## @end table Modified: trunk/octave-forge/main/control/inst/isstabilizable.m =================================================================== --- trunk/octave-forge/main/control/inst/isstabilizable.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/isstabilizable.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -39,6 +39,7 @@ ## Input matrix. ## @item e ## Descriptor matrix. +## If @var{e} is empty @code{[]} or not specified, an identity matrix is assumed. ## @item tol ## Optional tolerance for stability. Default value is 0. ## @item dflg = 0 Modified: trunk/octave-forge/main/control/inst/lqe.m =================================================================== --- trunk/octave-forge/main/control/inst/lqe.m 2012-06-22 15:52:36 UTC (rev 10673) +++ trunk/octave-forge/main/control/inst/lqe.m 2012-06-23 07:34:15 UTC (rev 10674) @@ -42,6 +42,7 @@ ## State transition matrix of continuous-time system (n-by-n). ## @item g ## Process noise matrix of continuous-time system (n-by-g). +## If @var{g} is empty @code{[]}, an identity matrix is assumed. ## @item c ## Measurement matrix of continuous-time system (p-by-n). ## @item q @@ -50,7 +51,7 @@ ## Measurement noise covariance matrix (p-by-p). ## @item s ## Optional cross term covariance matrix (g-by-p), s = cov(w,v). -## If @var{s} is not specified, a zero matrix is assumed. +## If @var{s} is empty @code{[]} or not specified, a zero matrix is assumed. ## @end table ## ## @strong{Outputs} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-06-23 14:07:25
|
Revision: 10675 http://octave.svn.sourceforge.net/octave/?rev=10675&view=rev Author: paramaniac Date: 2012-06-23 14:07:19 +0000 (Sat, 23 Jun 2012) Log Message: ----------- control: minor doc enhancements (2) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/isminimumphase.m trunk/octave-forge/main/control/inst/@lti/isstable.m trunk/octave-forge/main/control/inst/h2syn.m trunk/octave-forge/main/control/inst/hinfsyn.m Modified: trunk/octave-forge/main/control/inst/@lti/isminimumphase.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isminimumphase.m 2012-06-23 07:34:15 UTC (rev 10674) +++ trunk/octave-forge/main/control/inst/@lti/isminimumphase.m 2012-06-23 14:07:19 UTC (rev 10675) @@ -22,6 +22,29 @@ ## The zeros must lie in the left complex half-plane. ## The name minimum-phase refers to the fact that such a system has the ## minimum possible phase lag for the given magnitude response |sys(jw)|. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI system. +## @item tol +## Optional tolerance. Default value is 0. +## @end table +## +## @strong{Outputs} +## @table @var +## @item bool = 0 +## System is not minimum phase. +## @item bool = 1 +## System is minimum phase. +## @end table +## +## @example +## @group +## real (z) < -tol*(1 + abs (z)) continuous-time +## abs (z) < 1 - tol discrete-time +## @end group +## @end example ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/@lti/isstable.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isstable.m 2012-06-23 07:34:15 UTC (rev 10674) +++ trunk/octave-forge/main/control/inst/@lti/isstable.m 2012-06-23 14:07:19 UTC (rev 10675) @@ -19,6 +19,29 @@ ## @deftypefn {Function File} {@var{bool} =} isstable (@var{sys}) ## @deftypefnx {Function File} {@var{bool} =} isstable (@var{sys}, @var{tol}) ## Determine whether LTI system is stable. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI system. +## @item tol +## Optional tolerance for stability. Default value is 0. +## @end table +## +## @strong{Outputs} +## @table @var +## @item bool = 0 +## System is not stable. +## @item bool = 1 +## System is stable. +## @end table +## +## @example +## @group +## real (p) < -tol*(1 + abs (p)) continuous-time +## abs (p) < 1 - tol discrete-time +## @end group +## @end example ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/h2syn.m =================================================================== --- trunk/octave-forge/main/control/inst/h2syn.m 2012-06-23 07:34:15 UTC (rev 10674) +++ trunk/octave-forge/main/control/inst/h2syn.m 2012-06-23 14:07:19 UTC (rev 10675) @@ -24,11 +24,11 @@ ## @item P ## Generalized plant. Must be a proper/realizable LTI model. ## @item nmeas -## Number of measured outputs v. The last nmeas outputs of @var{P} are connected to the +## Number of measured outputs v. The last @var{nmeas} outputs of @var{P} are connected to the ## inputs of controller @var{K}. The remaining outputs z (indices 1 to p-nmeas) are used ## to calculate the H-2 norm. ## @item ncon -## Number of controlled inputs u. The last ncon inputs of @var{P} are connected to the +## Number of controlled inputs u. The last @var{ncon} inputs of @var{P} are connected to the ## outputs of controller @var{K}. The remaining inputs w (indices 1 to m-ncon) are excited ## by a harmonic test signal. ## @end table Modified: trunk/octave-forge/main/control/inst/hinfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/hinfsyn.m 2012-06-23 07:34:15 UTC (rev 10674) +++ trunk/octave-forge/main/control/inst/hinfsyn.m 2012-06-23 14:07:19 UTC (rev 10675) @@ -25,11 +25,11 @@ ## @item P ## Generalized plant. Must be a proper/realizable LTI model. ## @item nmeas -## Number of measured outputs v. The last nmeas outputs of @var{P} are connected to the +## Number of measured outputs v. The last @var{nmeas} outputs of @var{P} are connected to the ## inputs of controller @var{K}. The remaining outputs z (indices 1 to p-nmeas) are used ## to calculate the H-infinity norm. ## @item ncon -## Number of controlled inputs u. The last ncon inputs of @var{P} are connected to the +## Number of controlled inputs u. The last @var{ncon} inputs of @var{P} are connected to the ## outputs of controller @var{K}. The remaining inputs w (indices 1 to m-ncon) are excited ## by a harmonic test signal. ## @item gmax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-08 15:56:36
|
Revision: 10844 http://octave.svn.sourceforge.net/octave/?rev=10844&view=rev Author: paramaniac Date: 2012-08-08 15:56:29 +0000 (Wed, 08 Aug 2012) Log Message: ----------- control: doc enhancements Modified Paths: -------------- trunk/octave-forge/main/control/inst/WestlandLynx.m trunk/octave-forge/main/control/inst/augw.m trunk/octave-forge/main/control/inst/btamodred.m trunk/octave-forge/main/control/inst/mixsyn.m trunk/octave-forge/main/control/inst/spamodred.m Modified: trunk/octave-forge/main/control/inst/WestlandLynx.m =================================================================== --- trunk/octave-forge/main/control/inst/WestlandLynx.m 2012-08-08 13:19:12 UTC (rev 10843) +++ trunk/octave-forge/main/control/inst/WestlandLynx.m 2012-08-08 15:56:29 UTC (rev 10844) @@ -34,14 +34,12 @@ ## pitch rate q [rad/s] ## @end group ## @end example -## @example -## @group -## Reference: -## Skogestad, S. and Postlethwaite I. -## Multivariable Feedback Control: Analysis and Design -## Second Edition -## Wiley 2005 -## http://www.nt.ntnu.no/users/skoge/book/2nd_edition/matlab_m/matfiles.html +## +## @strong{References}@* +## [1] Skogestad, S. and Postlethwaite I. (2005) +## @cite{Multivariable Feedback Control: Analysis and Design: +## Second Edition}. Wiley. +## @url{http://www.nt.ntnu.no/users/skoge/book/2nd_edition/matlab_m/matfiles.html} ## @end group ## @end example ## @end deftypefn Modified: trunk/octave-forge/main/control/inst/augw.m =================================================================== --- trunk/octave-forge/main/control/inst/augw.m 2012-08-08 13:19:12 UTC (rev 10843) +++ trunk/octave-forge/main/control/inst/augw.m 2012-08-08 15:56:29 UTC (rev 10844) @@ -93,16 +93,12 @@ ## +--------+ ## @end group ## @end example -## @example -## @group -## Reference: -## Skogestad, S. and Postlethwaite I. -## Multivariable Feedback Control: Analysis and Design -## Second Edition -## Wiley 2005 -## Chapter 3.8: General Control Problem Formulation -## @end group -## @end example +## +## @strong{References}@* +## [1] Skogestad, S. and Postlethwaite I. (2005) +## @cite{Multivariable Feedback Control: Analysis and Design: +## Second Edition}. Wiley. +## ## @seealso{h2syn, hinfsyn, mixsyn} ## @end deftypefn Modified: trunk/octave-forge/main/control/inst/btamodred.m =================================================================== --- trunk/octave-forge/main/control/inst/btamodred.m 2012-08-08 13:19:12 UTC (rev 10843) +++ trunk/octave-forge/main/control/inst/btamodred.m 2012-08-08 15:56:29 UTC (rev 10844) @@ -211,23 +211,23 @@ ## ## @strong{References}@* ## [1] Enns, D. -## Model reduction with balanced realizations: An error bound -## and a frequency weighted generalization. +## @cite{Model reduction with balanced realizations: An error bound +## and a frequency weighted generalization}. ## Proc. 23-th CDC, Las Vegas, pp. 127-132, 1984. ## ## [2] Lin, C.-A. and Chiu, T.-Y. -## Model reduction via frequency-weighted balanced realization. +## @cite{Model reduction via frequency-weighted balanced realization}. ## Control Theory and Advanced Technology, vol. 8, ## pp. 341-351, 1992. ## ## [3] Sreeram, V., Anderson, B.D.O and Madievski, A.G. -## New results on frequency weighted balanced reduction -## technique. +## @cite{New results on frequency weighted balanced reduction +## technique}. ## Proc. ACC, Seattle, Washington, pp. 4004-4009, 1995. ## ## [4] Varga, A. and Anderson, B.D.O. -## Square-root balancing-free methods for the frequency-weighted -## balancing related model reduction. +## @cite{Square-root balancing-free methods for the frequency-weighted +## balancing related model reduction}. ## (report in preparation) ## ## Modified: trunk/octave-forge/main/control/inst/mixsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/mixsyn.m 2012-08-08 13:19:12 UTC (rev 10843) +++ trunk/octave-forge/main/control/inst/mixsyn.m 2012-08-08 15:56:29 UTC (rev 10844) @@ -124,22 +124,17 @@ ## Closed Loop: T = feedback (L) ## @end group ## @end example -## @example -## @group -## Reference: -## Skogestad, S. and Postlethwaite I. -## Multivariable Feedback Control: Analysis and Design -## Second Edition -## Wiley 2005 -## Chapter 3.8: General Control Problem Formulation -## @end group -## @end example ## ## @strong{Algorithm}@* ## Relies on commands @command{augw} and @command{hinfsyn}, ## which use SLICOT SB10FD and SB10DD by courtesy of ## @uref{http://www.slicot.org, NICONET e.V.} ## +## @strong{References}@* +## [1] Skogestad, S. and Postlethwaite I. (2005) +## @cite{Multivariable Feedback Control: Analysis and Design: +## Second Edition}. Wiley. +## ## @seealso{hinfsyn, augw} ## @end deftypefn Modified: trunk/octave-forge/main/control/inst/spamodred.m =================================================================== --- trunk/octave-forge/main/control/inst/spamodred.m 2012-08-08 13:19:12 UTC (rev 10843) +++ trunk/octave-forge/main/control/inst/spamodred.m 2012-08-08 15:56:29 UTC (rev 10844) @@ -194,23 +194,23 @@ ## ## @strong{References}@* ## [1] Enns, D. -## Model reduction with balanced realizations: An error bound -## and a frequency weighted generalization. +## @cite{Model reduction with balanced realizations: An error bound +## and a frequency weighted generalization}. ## Proc. 23-th CDC, Las Vegas, pp. 127-132, 1984. ## ## [2] Lin, C.-A. and Chiu, T.-Y. -## Model reduction via frequency-weighted balanced realization. +## @cite{Model reduction via frequency-weighted balanced realization}. ## Control Theory and Advanced Technology, vol. 8, ## pp. 341-351, 1992. ## ## [3] Sreeram, V., Anderson, B.D.O and Madievski, A.G. -## New results on frequency weighted balanced reduction -## technique. +## @cite{New results on frequency weighted balanced reduction +## technique}. ## Proc. ACC, Seattle, Washington, pp. 4004-4009, 1995. ## ## [4] Varga, A. and Anderson, B.D.O. -## Square-root balancing-free methods for the frequency-weighted -## balancing related model reduction. +## @cite{Square-root balancing-free methods for the frequency-weighted +## balancing related model reduction}. ## (report in preparation) ## ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-17 10:51:57
|
Revision: 10882 http://octave.svn.sourceforge.net/octave/?rev=10882&view=rev Author: paramaniac Date: 2012-08-17 10:51:51 +0000 (Fri, 17 Aug 2012) Log Message: ----------- control: mute warning in test Modified Paths: -------------- trunk/octave-forge/main/control/inst/@iddata/fft.m trunk/octave-forge/main/control/inst/__iddata_dim__.m Modified: trunk/octave-forge/main/control/inst/@iddata/fft.m =================================================================== --- trunk/octave-forge/main/control/inst/@iddata/fft.m 2012-08-16 21:00:23 UTC (rev 10881) +++ trunk/octave-forge/main/control/inst/@iddata/fft.m 2012-08-17 10:51:51 UTC (rev 10882) @@ -88,7 +88,10 @@ %!shared DATD, Y, U %! Y = 1:10; %! U = 20:-2:1; +%! W = warning ("query", "iddata:transpose"); +%! warning ("off", W.identifier); %! DAT = iddata (Y, U); %! DATD = fft (DAT); +%! warning (W.identifier, W.state); %!assert (DATD.y{1}, Y, 1e-10); %!assert (DATD.u{1}, U, 1e-10); Modified: trunk/octave-forge/main/control/inst/__iddata_dim__.m =================================================================== --- trunk/octave-forge/main/control/inst/__iddata_dim__.m 2012-08-16 21:00:23 UTC (rev 10881) +++ trunk/octave-forge/main/control/inst/__iddata_dim__.m 2012-08-17 10:51:51 UTC (rev 10882) @@ -43,11 +43,11 @@ endif if (ly < p) - warning ("iddata: more outputs than samples - matrice 'y' should probably be transposed"); + warning ("iddata:transpose", "iddata: more outputs than samples - matrice 'y' should probably be transposed"); endif if (lu < m) - warning ("iddata: more inputs than samples - matrice 'u' should probably be transposed"); + warning ("iddata:transpose", "iddata: more inputs than samples - matrice 'u' should probably be transposed"); endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-23 17:15:28
|
Revision: 10898 http://octave.svn.sourceforge.net/octave/?rev=10898&view=rev Author: paramaniac Date: 2012-08-23 17:15:22 +0000 (Thu, 23 Aug 2012) Log Message: ----------- control: rename key again to 'noiseinput' Modified Paths: -------------- trunk/octave-forge/main/control/inst/__slicot_identification__.m trunk/octave-forge/main/control/inst/moen4.m trunk/octave-forge/main/control/inst/moesp.m trunk/octave-forge/main/control/inst/n4sid.m Modified: trunk/octave-forge/main/control/inst/__slicot_identification__.m =================================================================== --- trunk/octave-forge/main/control/inst/__slicot_identification__.m 2012-08-23 16:18:49 UTC (rev 10897) +++ trunk/octave-forge/main/control/inst/__slicot_identification__.m 2012-08-23 17:15:22 UTC (rev 10898) @@ -115,7 +115,7 @@ rcond = val; case "confirm" conf = logical (val); - case {"input", "inputs"} + case {"noiseinput", "noiseinputs", "noise", "input", "inputs"} noise = val; otherwise warning ("%s: invalid property name '%s' ignored", method, key); Modified: trunk/octave-forge/main/control/inst/moen4.m =================================================================== --- trunk/octave-forge/main/control/inst/moen4.m 2012-08-23 16:18:49 UTC (rev 10897) +++ trunk/octave-forge/main/control/inst/moen4.m 2012-08-23 17:15:22 UTC (rev 10898) @@ -129,7 +129,7 @@ ## No confirmation. Default value. ## @end table ## -## @item 'input' +## @item 'noiseinput' ## The desired type of noise input channels. ## @table @var ## @item 'n' Modified: trunk/octave-forge/main/control/inst/moesp.m =================================================================== --- trunk/octave-forge/main/control/inst/moesp.m 2012-08-23 16:18:49 UTC (rev 10897) +++ trunk/octave-forge/main/control/inst/moesp.m 2012-08-23 17:15:22 UTC (rev 10898) @@ -128,7 +128,7 @@ ## No confirmation. Default value. ## @end table ## -## @item 'input' +## @item 'noiseinput' ## The desired type of noise input channels. ## @table @var ## @item 'n' Modified: trunk/octave-forge/main/control/inst/n4sid.m =================================================================== --- trunk/octave-forge/main/control/inst/n4sid.m 2012-08-23 16:18:49 UTC (rev 10897) +++ trunk/octave-forge/main/control/inst/n4sid.m 2012-08-23 17:15:22 UTC (rev 10898) @@ -128,7 +128,7 @@ ## No confirmation. Default value. ## @end table ## -## @item 'input' +## @item 'noiseinput' ## The desired type of noise input channels. ## @table @var ## @item 'n' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-25 05:44:30
|
Revision: 10912 http://octave.svn.sourceforge.net/octave/?rev=10912&view=rev Author: paramaniac Date: 2012-08-25 05:44:24 +0000 (Sat, 25 Aug 2012) Log Message: ----------- control: doc enhancements Modified Paths: -------------- trunk/octave-forge/main/control/inst/margin.m trunk/octave-forge/main/control/inst/sensitivity.m Modified: trunk/octave-forge/main/control/inst/margin.m =================================================================== --- trunk/octave-forge/main/control/inst/margin.m 2012-08-24 16:27:38 UTC (rev 10911) +++ trunk/octave-forge/main/control/inst/margin.m 2012-08-25 05:44:24 UTC (rev 10912) @@ -18,9 +18,11 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{gamma}, @var{phi}, @var{w_gamma}, @var{w_phi}] =} margin (@var{sys}) ## @deftypefnx{Function File} {[@var{gamma}, @var{phi}, @var{w_gamma}, @var{w_phi}] =} margin (@var{sys}, @var{tol}) -## Gain and phase margin of a system. If no output arguments are given, both gain and phase margin -## are plotted on a bode diagram. Otherwise, the margins and their corresponding frequencies are -## computed and returned. +## Gain and phase margin of a system. +## If no output arguments are given, both gain and phase margin are plotted on a bode diagram. +## Otherwise, the margins and their corresponding frequencies are computed and returned. +## A more robust criterion to assess the stability of a feedback system is the sensitivity Ms +## computed by command @command{sensitivity}. ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/sensitivity.m =================================================================== --- trunk/octave-forge/main/control/inst/sensitivity.m 2012-08-24 16:27:38 UTC (rev 10911) +++ trunk/octave-forge/main/control/inst/sensitivity.m 2012-08-25 05:44:24 UTC (rev 10912) @@ -37,7 +37,10 @@ ## ## @end ifnottex ## If no output arguments are given, the critical distance 1/Ms -## is plotted on a Nyquist diagram. +## is plotted on a Nyquist diagram. +## In contrast to gain and phase margin as computed by command +## @command{margin}, the sensitivity @var{Ms} is a more robust +## criterion to assess the stability of a feedback system. ## ## @strong{Inputs} ## @table @var This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-08-25 06:15:07
|
Revision: 10913 http://octave.svn.sourceforge.net/octave/?rev=10913&view=rev Author: paramaniac Date: 2012-08-25 06:15:01 +0000 (Sat, 25 Aug 2012) Log Message: ----------- control: fix tex warning by replacing \ by \\ Modified Paths: -------------- trunk/octave-forge/main/control/inst/ctrbf.m trunk/octave-forge/main/control/inst/obsvf.m Modified: trunk/octave-forge/main/control/inst/ctrbf.m =================================================================== --- trunk/octave-forge/main/control/inst/ctrbf.m 2012-08-25 05:44:24 UTC (rev 10912) +++ trunk/octave-forge/main/control/inst/ctrbf.m 2012-08-25 06:15:01 UTC (rev 10913) @@ -27,7 +27,7 @@ ## ## @example ## @group -## Abar = Tc \ A * Tc , Bbar = Tc \ B , Cbar = C * Tc +## Abar = Tc \\ A * Tc , Bbar = Tc \\ B , Cbar = C * Tc ## @end group ## @end example ## Modified: trunk/octave-forge/main/control/inst/obsvf.m =================================================================== --- trunk/octave-forge/main/control/inst/obsvf.m 2012-08-25 05:44:24 UTC (rev 10912) +++ trunk/octave-forge/main/control/inst/obsvf.m 2012-08-25 06:15:01 UTC (rev 10913) @@ -27,7 +27,7 @@ ## ## @example ## @group -## Abar = To \ A * To , Bbar = To \ B , Cbar = C * To +## Abar = To \\ A * To , Bbar = To \\ B , Cbar = C * To ## @end group ## @end example ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-12 10:39:16
|
Revision: 10997 http://octave.svn.sourceforge.net/octave/?rev=10997&view=rev Author: paramaniac Date: 2012-09-12 10:39:10 +0000 (Wed, 12 Sep 2012) Log Message: ----------- control: remove anonymous function calls in cellfun statements if possible Modified Paths: -------------- trunk/octave-forge/main/control/inst/@iddata/cat.m trunk/octave-forge/main/control/inst/@iddata/detrend.m trunk/octave-forge/main/control/inst/@iddata/diff.m trunk/octave-forge/main/control/inst/@iddata/resample.m trunk/octave-forge/main/control/inst/__adjust_iddata_tsam__.m Modified: trunk/octave-forge/main/control/inst/@iddata/cat.m =================================================================== --- trunk/octave-forge/main/control/inst/@iddata/cat.m 2012-09-11 09:09:31 UTC (rev 10996) +++ trunk/octave-forge/main/control/inst/@iddata/cat.m 2012-09-12 10:39:10 UTC (rev 10997) @@ -231,7 +231,7 @@ if (nargin > 1) ## compare n-th string of first cell with n-th string of remaining cells - tmp = cellfun (@(x) strcmp (str, x), varargin, "uniformoutput", false); + tmp = cellfun (@strcmp, {str}, varargin, "uniformoutput", false); ## check whether all strings of each pair are equal tmp = cellfun (@all, tmp); ## check whether all pairs are equal Modified: trunk/octave-forge/main/control/inst/@iddata/detrend.m =================================================================== --- trunk/octave-forge/main/control/inst/@iddata/detrend.m 2012-09-11 09:09:31 UTC (rev 10996) +++ trunk/octave-forge/main/control/inst/@iddata/detrend.m 2012-09-12 10:39:10 UTC (rev 10997) @@ -40,8 +40,8 @@ [n, p, m] = size (dat); - dat.y = cellfun (@(y) detrend (y, ord), dat.y, "uniformoutput", false); - dat.u = cellfun (@(u) detrend (u, ord), dat.u, "uniformoutput", false); + dat.y = cellfun (@detrend, dat.y, {ord}, "uniformoutput", false); + dat.u = cellfun (@detrend, dat.u, {ord}, "uniformoutput", false); ## if a MIMO experiment has only 1 sample, detrend works ## row-wisely instead of column-wisely Modified: trunk/octave-forge/main/control/inst/@iddata/diff.m =================================================================== --- trunk/octave-forge/main/control/inst/@iddata/diff.m 2012-09-11 09:09:31 UTC (rev 10996) +++ trunk/octave-forge/main/control/inst/@iddata/diff.m 2012-09-12 10:39:10 UTC (rev 10997) @@ -32,7 +32,7 @@ print_usage (); endif - dat.y = cellfun (@(y) diff (y, k, 1), dat.y, "uniformoutput", false); - dat.u = cellfun (@(u) diff (u, k, 1), dat.u, "uniformoutput", false); + dat.y = cellfun (@diff, dat.y, {k}, {1}, "uniformoutput", false); + dat.u = cellfun (@diff, dat.u, {k}, {1}, "uniformoutput", false); endfunction Modified: trunk/octave-forge/main/control/inst/@iddata/resample.m =================================================================== --- trunk/octave-forge/main/control/inst/@iddata/resample.m 2012-09-11 09:09:31 UTC (rev 10996) +++ trunk/octave-forge/main/control/inst/@iddata/resample.m 2012-09-12 10:39:10 UTC (rev 10997) @@ -66,7 +66,7 @@ error ("iddata: resample: fourth argument invalid"); endif - dat.y = cellfun (@(y) resample (y, p, q, h), dat.y, "uniformoutput", false); - dat.u = cellfun (@(u) resample (u, p, q, h), dat.u, "uniformoutput", false); + dat.y = cellfun (@resample, dat.y, {p}, {q}, {h}, "uniformoutput", false); + dat.u = cellfun (@resample, dat.u, {p}, {q}, {h}, "uniformoutput", false); endfunction Modified: trunk/octave-forge/main/control/inst/__adjust_iddata_tsam__.m =================================================================== --- trunk/octave-forge/main/control/inst/__adjust_iddata_tsam__.m 2012-09-11 09:09:31 UTC (rev 10996) +++ trunk/octave-forge/main/control/inst/__adjust_iddata_tsam__.m 2012-09-12 10:39:10 UTC (rev 10997) @@ -34,7 +34,7 @@ tsam = {tsam}; endif - tmp = cellfun (@(x) issample (x, -1), tsam); + tmp = cellfun (@issample, tsam, {-1}); if (any (! tmp)) error ("iddata: invalid sampling time"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-14 11:55:49
|
Revision: 11013 http://octave.svn.sourceforge.net/octave/?rev=11013&view=rev Author: paramaniac Date: 2012-09-14 11:55:40 +0000 (Fri, 14 Sep 2012) Log Message: ----------- control: fix bug, use new multiplot bode in example Madievski.m Modified Paths: -------------- trunk/octave-forge/main/control/inst/Madievski.m trunk/octave-forge/main/control/inst/__frequency_response__.m Modified: trunk/octave-forge/main/control/inst/Madievski.m =================================================================== --- trunk/octave-forge/main/control/inst/Madievski.m 2012-09-14 11:44:35 UTC (rev 11012) +++ trunk/octave-forge/main/control/inst/Madievski.m 2012-09-14 11:55:40 UTC (rev 11013) @@ -86,30 +86,7 @@ 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]') +bode (K, Kr4, Kr2, w) legend ('K (8 states)', 'Kr (4 states)', 'Kr (2 states)', 'location', 'southwest') % Step Response of Closed Loop Modified: trunk/octave-forge/main/control/inst/__frequency_response__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_response__.m 2012-09-14 11:44:35 UTC (rev 11012) +++ trunk/octave-forge/main/control/inst/__frequency_response__.m 2012-09-14 11:55:40 UTC (rev 11013) @@ -50,7 +50,7 @@ error ("frequency_response: invalid cell"); endif elseif (any (w_idx)) # are there any frequency vectors? - w = args(w_idx){end}; + w = args(w_idx)(end); else # there are neither frequency ranges nor vectors w = __frequency_vector__ (sys_cell, wbounds); endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-14 17:01:30
|
Revision: 11016 http://octave.svn.sourceforge.net/octave/?rev=11016&view=rev Author: paramaniac Date: 2012-09-14 17:01:20 +0000 (Fri, 14 Sep 2012) Log Message: ----------- control: fix bug Modified Paths: -------------- trunk/octave-forge/main/control/inst/__frequency_vector__.m trunk/octave-forge/main/control/inst/nyquist.m Modified: trunk/octave-forge/main/control/inst/__frequency_vector__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_vector__.m 2012-09-14 14:31:20 UTC (rev 11015) +++ trunk/octave-forge/main/control/inst/__frequency_vector__.m 2012-09-14 17:01:20 UTC (rev 11016) @@ -42,7 +42,7 @@ isc = iscell (sys_cell); if (! isc) # __sys2frd__ methods pass LTI models not in cells - sys_cell = {sys_cell} + sys_cell = {sys_cell}; endif idx = cellfun (@(x) isa (x, "lti"), sys_cell); @@ -53,14 +53,12 @@ if (strcmpi (wbounds, "std")) # plots with explicit frequencies - if (nargin == 2) - dec_min = min (cell2mat (dec_min)); - dec_max = max (cell2mat (dec_max)); - elseif (nargin == 4) # w = {wmin, wmax} + if (nargin == 4) # w = {wmin, wmax} dec_min = log10 (wmin); dec_max = log10 (wmax); else - print_usage (); + dec_min = min (cell2mat (dec_min)); + dec_max = max (cell2mat (dec_max)); endif zp = horzcat (zp{:}); Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2012-09-14 14:31:20 UTC (rev 11015) +++ trunk/octave-forge/main/control/inst/nyquist.m 2012-09-14 17:01:20 UTC (rev 11016) @@ -50,7 +50,7 @@ ## Created: November 2009 ## Version: 0.4 -function [re_r, im_r, w_r] = nyquist2 (varargin) +function [re_r, im_r, w_r] = nyquist (varargin) if (nargin == 0) print_usage (); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-14 18:38:07
|
Revision: 11019 http://octave.svn.sourceforge.net/octave/?rev=11019&view=rev Author: paramaniac Date: 2012-09-14 18:38:01 +0000 (Fri, 14 Sep 2012) Log Message: ----------- control: fix margin Modified Paths: -------------- trunk/octave-forge/main/control/inst/__frequency_response__.m trunk/octave-forge/main/control/inst/margin.m Modified: trunk/octave-forge/main/control/inst/__frequency_response__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_response__.m 2012-09-14 18:20:47 UTC (rev 11018) +++ trunk/octave-forge/main/control/inst/__frequency_response__.m 2012-09-14 18:38:01 UTC (rev 11019) @@ -25,10 +25,12 @@ function [H, w] = __frequency_response__ (args, mimoflag = 0, resptype = 0, wbounds = "std", cellflag = false) - %if (! iscell (args)) - % args = {args}; - %endif + isc = iscell (args); + if (! isc) + args = {args}; + endif + sys_idx = cellfun (@isa, args, {"lti"}); # look for LTI models w_idx = cellfun (@(x) is_real_vector (x) && length (x) > 1, args); # look for frequency vectors r_idx = cellfun (@iscell, args); # look for frequency ranges {wmin, wmax} @@ -65,4 +67,9 @@ ## restore frequency vectors of FRD models in w w(frd_idx) = w_frd; + if (! isc) # for old non-multiplot functions + H = H{1}; + w = w{1}; + endif + endfunction Modified: trunk/octave-forge/main/control/inst/margin.m =================================================================== --- trunk/octave-forge/main/control/inst/margin.m 2012-09-14 18:20:47 UTC (rev 11018) +++ trunk/octave-forge/main/control/inst/margin.m 2012-09-14 18:38:01 UTC (rev 11019) @@ -269,7 +269,7 @@ if (nargout == 0) # show bode diagram - [H, w] = __frequency_response__ (sys, [], false, 0, "std"); + [H, w] = __frequency_response__ (sys, false, 0, "std"); H = reshape (H, [], 1); mag_db = 20 * log10 (abs (H)); @@ -301,14 +301,14 @@ endif subplot (2, 1, 1) - semilogx (w, mag_db, "b", wv, [0, 0], ":k", wgm, mgmh, ":k", wgm, mgm, "r", wpm, mpm, ":k") + semilogx (w, mag_db, "b", wv, [0, 0], "-.k", wgm, mgmh, "-.k", wgm, mgm, "r", wpm, mpm, "-.k") axis (ax_vec_mag) grid ("on") title (title_str) ylabel ("Magnitude [dB]") subplot (2, 1, 2) - semilogx (w, pha, "b", wv, [-180, -180], ":k", wgm, pgm, ":k", wpm, ppmh, ":k", wpm, ppm, "r") + semilogx (w, pha, "b", wv, [-180, -180], "-.k", wgm, pgm, "-.k", wpm, ppmh, "-.k", wpm, ppm, "r") axis (ax_vec_pha) grid ("on") xlabel (xl_str) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-15 07:07:25
|
Revision: 11025 http://octave.svn.sourceforge.net/octave/?rev=11025&view=rev Author: paramaniac Date: 2012-09-15 07:07:18 +0000 (Sat, 15 Sep 2012) Log Message: ----------- control: document multiplot feature in helpstring (deftypefn) Modified Paths: -------------- trunk/octave-forge/main/control/inst/bode.m trunk/octave-forge/main/control/inst/bodemag.m trunk/octave-forge/main/control/inst/nichols.m trunk/octave-forge/main/control/inst/nyquist.m trunk/octave-forge/main/control/inst/pzmap.m trunk/octave-forge/main/control/inst/sigma.m Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2012-09-14 21:33:53 UTC (rev 11024) +++ trunk/octave-forge/main/control/inst/bode.m 2012-09-15 07:07:18 UTC (rev 11025) @@ -16,7 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{mag}, @var{pha}, @var{w}] =} bode (@var{sys}) +## @deftypefn {Function File} bode (@var{sys}) +## @deftypefnx {Function File} bode (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}) +## @deftypefnx {Function File} bode (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}, @var{w}) +## @deftypefnx {Function File} bode (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}) +## @deftypefnx {Function File} {[@var{mag}, @var{pha}, @var{w}] =} bode (@var{sys}) ## @deftypefnx {Function File} {[@var{mag}, @var{pha}, @var{w}] =} bode (@var{sys}, @var{w}) ## Bode diagram of frequency response. If no output arguments are given, ## the response is printed on the screen. Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2012-09-14 21:33:53 UTC (rev 11024) +++ trunk/octave-forge/main/control/inst/bodemag.m 2012-09-15 07:07:18 UTC (rev 11025) @@ -16,7 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{mag}, @var{w}] =} bodemag (@var{sys}) +## @deftypefn {Function File} bodemag (@var{sys}) +## @deftypefnx {Function File} bodemag (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}) +## @deftypefnx {Function File} bodemag (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}, @var{w}) +## @deftypefnx {Function File} bodemag (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}) +## @deftypefnx {Function File} {[@var{mag}, @var{w}] =} bodemag (@var{sys}) ## @deftypefnx {Function File} {[@var{mag}, @var{w}] =} bodemag (@var{sys}, @var{w}) ## Bode magnitude diagram of frequency response. If no output arguments are given, ## the response is printed on the screen. Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2012-09-14 21:33:53 UTC (rev 11024) +++ trunk/octave-forge/main/control/inst/nichols.m 2012-09-15 07:07:18 UTC (rev 11025) @@ -16,7 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{mag}, @var{pha}, @var{w}] =} nichols (@var{sys}) +## @deftypefn {Function File} nichols (@var{sys}) +## @deftypefnx {Function File} nichols (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}) +## @deftypefnx {Function File} nichols (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}, @var{w}) +## @deftypefnx {Function File} nichols (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}) +## @deftypefnx {Function File} {[@var{mag}, @var{pha}, @var{w}] =} nichols (@var{sys}) ## @deftypefnx {Function File} {[@var{mag}, @var{pha}, @var{w}] =} nichols (@var{sys}, @var{w}) ## Nichols chart of frequency response. If no output arguments are given, ## the response is printed on the screen. Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2012-09-14 21:33:53 UTC (rev 11024) +++ trunk/octave-forge/main/control/inst/nyquist.m 2012-09-15 07:07:18 UTC (rev 11025) @@ -16,7 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{re}, @var{im}, @var{w}] =} nyquist (@var{sys}) +## @deftypefn {Function File} nyquist (@var{sys}) +## @deftypefnx {Function File} nyquist (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}) +## @deftypefnx {Function File} nyquist (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}, @var{w}) +## @deftypefnx {Function File} nyquist (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}) +## @deftypefnx {Function File} {[@var{re}, @var{im}, @var{w}] =} nyquist (@var{sys}) ## @deftypefnx {Function File} {[@var{re}, @var{im}, @var{w}] =} nyquist (@var{sys}, @var{w}) ## Nyquist diagram of frequency response. If no output arguments are given, ## the response is printed on the screen. Modified: trunk/octave-forge/main/control/inst/pzmap.m =================================================================== --- trunk/octave-forge/main/control/inst/pzmap.m 2012-09-14 21:33:53 UTC (rev 11024) +++ trunk/octave-forge/main/control/inst/pzmap.m 2012-09-15 07:07:18 UTC (rev 11025) @@ -17,6 +17,8 @@ ## -*- texinfo -*- ## @deftypefn {Function File} pzmap (@var{sys}) +## @deftypefnx {Function File} pzmap (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}) +## @deftypefnx {Function File} pzmap (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}) ## @deftypefnx {Function File} {[@var{p}, @var{z}] =} pzmap (@var{sys}) ## Plot the poles and zeros of an LTI system in the complex plane. ## If no output arguments are given, the result is plotted on the screen. Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2012-09-14 21:33:53 UTC (rev 11024) +++ trunk/octave-forge/main/control/inst/sigma.m 2012-09-15 07:07:18 UTC (rev 11025) @@ -16,7 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{sv}, @var{w}] =} sigma (@var{sys}) +## @deftypefn {Function File} sigma (@var{sys}) +## @deftypefnx {Function File} sigma (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}) +## @deftypefnx {Function File} sigma (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}, @var{w}) +## @deftypefnx {Function File} sigma (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}) +## @deftypefnx{Function File} {[@var{sv}, @var{w}] =} sigma (@var{sys}) ## @deftypefnx{Function File} {[@var{sv}, @var{w}] =} sigma (@var{sys}, @var{w}) ## @deftypefnx{Function File} {[@var{sv}, @var{w}] =} sigma (@var{sys}, @var{[]}, @var{ptype}) ## @deftypefnx{Function File} {[@var{sv}, @var{w}] =} sigma (@var{sys}, @var{w}, @var{ptype}) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-15 11:15:56
|
Revision: 11026 http://octave.svn.sourceforge.net/octave/?rev=11026&view=rev Author: paramaniac Date: 2012-09-15 11:15:50 +0000 (Sat, 15 Sep 2012) Log Message: ----------- control: solve possible problem with inputname Modified Paths: -------------- trunk/octave-forge/main/control/inst/bode.m trunk/octave-forge/main/control/inst/bodemag.m trunk/octave-forge/main/control/inst/nichols.m trunk/octave-forge/main/control/inst/nyquist.m trunk/octave-forge/main/control/inst/pzmap.m trunk/octave-forge/main/control/inst/sigma.m Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2012-09-15 07:07:18 UTC (rev 11025) +++ trunk/octave-forge/main/control/inst/bode.m 2012-09-15 11:15:50 UTC (rev 11026) @@ -77,7 +77,7 @@ len = numel (H); mag_args = {}; pha_args = {}; - legend_args = cell (len, 1); + legend_args = {}; for k = 1:len if (k == len) @@ -88,7 +88,9 @@ style = varargin(style_idx(style_idx > sys_idx(k) & style_idx <= lim)); mag_args = cat (2, mag_args, w(k), mag_db(k), style); pha_args = cat (2, pha_args, w(k), pha(k), style); - legend_args{k} = inputname(sys_idx(k)); # watch out for bode (lticell{:}) + try + legend_args = cat (2, legend_args, inputname(sys_idx(k))); # watch out for bode (lticell{:}) + end_try_catch endfor subplot (2, 1, 1) Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2012-09-15 07:07:18 UTC (rev 11025) +++ trunk/octave-forge/main/control/inst/bodemag.m 2012-09-15 11:15:50 UTC (rev 11026) @@ -73,7 +73,7 @@ len = numel (H); mag_args = {}; - legend_args = cell (len, 1); + legend_args = {}; for k = 1:len if (k == len) @@ -83,7 +83,9 @@ endif style = varargin(style_idx(style_idx > sys_idx(k) & style_idx <= lim)); mag_args = cat (2, mag_args, w(k), mag_db(k), style); - legend_args{k} = inputname(sys_idx(k)); # watch out for bode (lticell{:}) + try + legend_args = cat (2, legend_args, inputname(sys_idx(k))); # watch out for bodemag (lticell{:}) + end_try_catch endfor semilogx (mag_args{:}) Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2012-09-15 07:07:18 UTC (rev 11025) +++ trunk/octave-forge/main/control/inst/nichols.m 2012-09-15 11:15:50 UTC (rev 11026) @@ -86,7 +86,11 @@ endif style = varargin(style_idx(style_idx > sys_idx(k) & style_idx <= lim)); plot_args = cat (2, plot_args, pha(k), mag_db(k), style); - legend_args{k} = inputname(sys_idx(k)); # watch out for nichols (lticell{:}) + try + legend_args{k} = inputname(sys_idx(k)); + catch + legend_args{k} = ""; + end_try_catch endfor plot (plot_args{:}) Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2012-09-15 07:07:18 UTC (rev 11025) +++ trunk/octave-forge/main/control/inst/nyquist.m 2012-09-15 11:15:50 UTC (rev 11026) @@ -94,7 +94,11 @@ pos_args = cat (2, pos_args, re{k}, im{k}, style); neg_args = cat (2, neg_args, re{k}, -im{k}, style); endif - legend_args{k} = inputname(sys_idx(k)); + try + legend_args{k} = inputname(sys_idx(k)); + catch + legend_args{k} = ""; + end_try_catch endfor ## FIXME: pos_args = cat (2, pos_args, re{k}, im{k}, {"-", "color", col}, style); Modified: trunk/octave-forge/main/control/inst/pzmap.m =================================================================== --- trunk/octave-forge/main/control/inst/pzmap.m 2012-09-15 07:07:18 UTC (rev 11025) +++ trunk/octave-forge/main/control/inst/pzmap.m 2012-09-15 11:15:50 UTC (rev 11026) @@ -86,11 +86,14 @@ pol_args = cat (2, pol_args, pol_re{k}, pol_im{k}, style); zer_args = cat (2, zer_args, zer_re{k}, zer_im{k}, style); endif + try + legend_args{k} = inputname(sys_idx(k)); + catch + legend_args{k} = ""; + end_try_catch + endfor - ## FIXME: try to combine "x", "o" and style for custom colors - - legend_args{k} = inputname(sys_idx(k)); - endfor + ## FIXME: try to combine "x", "o" and style for custom colors h = plot (pol_args{:}, zer_args{:}); grid ("on") Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2012-09-15 07:07:18 UTC (rev 11025) +++ trunk/octave-forge/main/control/inst/sigma.m 2012-09-15 11:15:50 UTC (rev 11026) @@ -106,7 +106,11 @@ else plot_args = cat (2, plot_args, w(k), sv_db(k), style); endif - legend_args{k} = inputname(sys_idx(k)); # watch out for sigma (lticell{:}) + try + legend_args{k} = inputname(sys_idx(k)); # watch out for sigma (lticell{:}) + catch + legend_args{k} = ""; + end_try_catch endfor ## adjust line colors in legend This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-09-22 10:23:30
|
Revision: 11074 http://octave.svn.sourceforge.net/octave/?rev=11074&view=rev Author: paramaniac Date: 2012-09-22 10:23:23 +0000 (Sat, 22 Sep 2012) Log Message: ----------- control: move multiplot time response into place Modified Paths: -------------- trunk/octave-forge/main/control/inst/__time_response__.m trunk/octave-forge/main/control/inst/step.m Modified: trunk/octave-forge/main/control/inst/__time_response__.m =================================================================== --- trunk/octave-forge/main/control/inst/__time_response__.m 2012-09-22 10:14:12 UTC (rev 11073) +++ trunk/octave-forge/main/control/inst/__time_response__.m 2012-09-22 10:23:23 UTC (rev 11074) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -20,241 +20,350 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.2 +## Version: 0.3 -function [y, t, x_arr] = __time_response__ (sys, resptype, plotflag, tfinal, dt, x0, sysname) +function [y, t, x] = __time_response__ (response, args, sysname, plotflag) - if (! isa (sys, "ss")) - sys = ss (sys); # sys must be proper - endif + sys_idx = find (cellfun (@isa, args, {"lti"})); # look for LTI models, 'find' needed for plot styles + sys_cell = cellfun (@ss, args(sys_idx), "uniformoutput", false); # convert to state-space - if (is_real_vector (tfinal) && length (tfinal) > 1) # time vector t passed - dt = tfinal(2) - tfinal(1); # assume that t is regularly spaced - tfinal = tfinal(end); + if (! size_equal (sys_cell{:})) + error ("%s: models must have equal sizes", response); endif - [A, B, C, D, tsam] = ssdata (sys); + vec_idx = find (cellfun (@is_real_matrix, args)); # indices of vector arguments + n_vec = length (vec_idx); # number of vector arguments + n_sys = length (sys_cell); # number of LTI systems - discrete = ! isct (sys); # static gains are treated as analog systems - tsam = abs (tsam); # use 1 second if tsam is unspecified (-1) + tfinal = []; + dt = []; + x0 = []; - if (discrete) - if (! isempty (dt)) - warning ("time_response: argument dt has no effect on sampling time of discrete system"); + ## extract tfinal/t, dt, x0 from args + if (strcmpi (response, "initial")) + if (n_vec < 1) + error ("initial: require initial state vector 'x0'"); + else # initial state vector x0 specified + arg = args{vec_idx(1)}; + if (is_real_vector (arg)) + x0 = arg; + else + error ("initial: initial state vector 'x0' must be a vector of real values"); + endif + if (n_vec > 1) # tfinal or time vector t specified + arg = args{vec_idx(2)}; + if (issample (arg)) + tfinal = arg; + elseif (isempty (arg)) + ## tfinal = []; # nothing to do here + elseif (is_real_vector (arg)) + dt = abs (arg(2) - arg(1)); # assume that t is regularly spaced + tfinal = arg(end); + else + warning ("initial: argument number %d ignored", vec_idx(2)); + endif + if (n_vec > 2) # sampling time dt specified + arg = args{vec_idx(3)}; + if (issample (arg)) + dt = arg; + else + warning ("initial: argument number %d ignored", vec_idx(3)); + endif + if (n_vec > 3) + warning ("initial: ignored"); + endif + endif + endif + endif + else # step or impulse response + if (n_vec > 0) # tfinal or time vector t specified + arg = args{vec_idx(1)}; + if (issample (arg)) + tfinal = arg; + elseif (isempty (arg)) + ## tfinal = []; # nothing to do here + elseif (is_real_vector (arg)) + dt = abs (arg(2) - arg(1)); # assume that t is regularly spaced + tfinal = arg(end); + else + warning ("%s: argument number %d ignored", response, vec_idx(1)); + endif + if (n_vec > 1) # sampling time dt specified + arg = args{vec_idx(2)}; + if (issample (arg)) + dt = arg; + else + warning ("%s: argument number %d ignored", response, vec_idx(2)); + endif + if (n_vec > 2) + warning ("%s: ignored", response); + endif + endif endif - - dt = tsam; endif + ## TODO: share common code between initial and step/impulse - [tfinal, dt] = __sim_horizon__ (A, discrete, tfinal, dt); + [tfinal, dt] = cellfun (@__sim_horizon__, sys_cell, {tfinal}, {dt}, "uniformoutput", false); + tfinal = max ([tfinal{:}]); - if (! discrete) - sys = c2d (sys, dt, "zoh"); - endif + ct_idx = cellfun (@isct, sys_cell); + sys_dt_cell = sys_cell; + tmp = cellfun (@c2d, sys_cell(ct_idx), dt(ct_idx), {"zoh"}, "uniformoutput", false); + sys_dt_cell(ct_idx) = tmp; - [F, G] = ssdata (sys); # matrices C and D don't change + ## time vector + t = @cellfun (@(dt) reshape (0 : dt : tfinal, [], 1), dt, "uniformoutput", false); - n = rows (F); # number of states - m = columns (G); # number of inputs - p = rows (C); # number of outputs + ## function [y, x_arr] = __initial_response__ (sys, sys_dt, t, x0) + ## function [y, x_arr] = __step_response__ (sys_dt, t) + ## function [y, x_arr] = __impulse_response__ (sys, sys_dt, t) - ## time vector - t = reshape (0 : dt : tfinal, [], 1); - l_t = length (t); - - switch (resptype) + switch (response) case "initial" - str = ["Response of ", sysname, " to Initial Conditions"]; - yfinal = zeros (p, 1); + [y, x] = cellfun (@__initial_response__, sys_dt_cell, t, {x0}, "uniformoutput", false); + case "step" + [y, x] = cellfun (@__step_response__, sys_dt_cell, t, "uniformoutput", false); + case "impulse" + [y, x] = cellfun (@__impulse_response__, sys_cell, sys_dt_cell, t, "uniformoutput", false); + otherwise + error ("time_response: invalid response type"); + endswitch - ## preallocate memory - y = zeros (l_t, p); - x_arr = zeros (l_t, n); - ## initial conditions - x = reshape (x0, [], 1); # make sure that x is a column vector - - if (n != length (x0) || ! is_real_vector (x0)) - error ("initial: x0 must be a real vector with %d elements", n); + if (plotflag) # display plot + [p, m] = size (sys_cell{1}); + switch (response) + case "initial" + str = "Response to Initial Conditions"; + cols = 1; + ## yfinal = zeros (p, 1); + case "step" + str = "Step Response"; + cols = m; + ## yfinal = dcgain (sys_cell{1}); + case "impulse" + str = "Impulse Response"; + cols = m; + ## yfinal = zeros (p, m); + otherwise + error ("time_response: invalid response type"); + endswitch + + style_idx = find (cellfun (@ischar, args)); + outname = get (sys_cell{end}, "outname"); + outname = __labels__ (outname, "y"); + colororder = get (gca, "colororder"); + rc = rows (colororder); + + for k = 1 : n_sys # for every system + if (k == n_sys) + lim = numel (args); + else + lim = sys_idx(k+1); endif + style = args(style_idx(style_idx > sys_idx(k) & style_idx <= lim)); + if (isempty (style)) + color = colororder(1+rem (k-1, rc), :); + style = {"color", color}; + endif + discrete = ! ct_idx(k); + if (discrete) # discrete-time system + for i = 1 : p # for every output + for j = 1 : cols # for every input (except for initial where cols=1) + subplot (p, cols, (i-1)*cols+j); + stairs (t{k}, y{k}(:, i, j), style{:}); + hold on; + grid on; + if (k == n_sys) + axis tight; + ylim (__axis_margin__ (ylim)) + if (j == 1) + ylabel (outname{i}); + if (i == 1) + title (str); + endif + endif + endif + endfor + endfor + else # continuous-time system + for i = 1 : p # for every output + for j = 1 : cols # for every input (except for initial where cols=1) + subplot (p, cols, (i-1)*cols+j); + ##if (n_sys == 1 && isstable (sys_cell{1})) + ## plot (t{k}, y{k}(:, i, j), style{:}, [t{k}(1), t{k}(end)], repmat (yfinal(i,j), 1, 2)); + ## ## TODO: plot final value first such that its line doesn't overprint the response + ##else + plot (t{k}, y{k}(:, i, j), style{:}); + ##endif + hold on; + grid on; + if (k == n_sys) + axis tight + ylim (__axis_margin__ (ylim)) + if (j == 1) + ylabel (outname{i}); + if (i == 1) + title (str); + endif + endif + endif + endfor + endfor + endif + endfor + xlabel ("Time [s]"); + if (p == 1 && m == 1) + legend (sysname) + endif + hold off; + endif - ## simulation - for k = 1 : l_t - y(k, :) = C * x; - x_arr(k, :) = x; - x = F * x; - endfor +endfunction - case "step" - str = ["Step Response of ", sysname]; - yfinal = dcgain (sys); - ## preallocate memory - y = zeros (l_t, p, m); - x_arr = zeros (l_t, n, m); +function [y, x_arr] = __initial_response__ (sys_dt, t, x0) - for j = 1 : m # for every input channel - ## initial conditions - x = zeros (n, 1); - u = zeros (m, 1); - u(j) = 1; + [F, G, C, D] = ssdata (sys_dt); # system must be proper - ## simulation - for k = 1 : l_t - y(k, :, j) = C * x + D * u; - x_arr(k, :, j) = x; - x = F * x + G * u; - endfor - endfor + n = rows (F); # number of states + m = columns (G); # number of inputs + p = rows (C); # number of outputs + l_t = length (t); - case "impulse" - str = ["Impulse Response of ", sysname]; - yfinal = zeros (p, m); + ## preallocate memory + y = zeros (l_t, p); + x_arr = zeros (l_t, n); - ## preallocate memory - y = zeros (l_t, p, m); - x_arr = zeros (l_t, n, m); + ## initial conditions + x = reshape (x0, [], 1); # make sure that x is a column vector - for j = 1 : m # for every input channel - ## initial conditions - u = zeros (m, 1); - u(j) = 1; + if (n != length (x0) || ! is_real_vector (x0)) + error ("initial: x0 must be a real vector with %d elements", n); + endif - if (discrete) - x = zeros (n, 1); # zero by definition - y(1, :, j) = D * u / dt; - x_arr(1, :, j) = x; - x = G * u / dt; - else - x = B * u; # B, not G! - y(1, :, j) = C * x; - x_arr(1, :, j) = x; - x = F * x; - endif + ## simulation + for k = 1 : l_t + y(k, :) = C * x; + x_arr(k, :) = x; + x = F * x; + endfor - ## simulation - for k = 2 : l_t - y (k, :, j) = C * x; - x_arr(k, :, j) = x; - x = F * x; - endfor - endfor - - if (discrete) - y *= dt; - x_arr *= dt; - endif - - otherwise - error ("time_response: invalid response type"); - - endswitch - +endfunction - if (plotflag) # display plot - ## TODO: Set correct titles, especially for multi-input systems +function [y, x_arr] = __step_response__ (sys_dt, t) - stable = isstable (sys); - outname = get (sys, "outname"); - outname = __labels__ (outname, "y_"); + [F, G, C, D] = ssdata (sys_dt); # system must be proper - if (strcmp (resptype, "initial")) - cols = 1; - else - cols = m; - endif + n = rows (F); # number of states + m = columns (G); # number of inputs + p = rows (C); # number of outputs + l_t = length (t); - if (discrete) # discrete system - for k = 1 : p - for j = 1 : cols + ## preallocate memory + y = zeros (l_t, p, m); + x_arr = zeros (l_t, n, m); - subplot (p, cols, (k-1)*cols+j); + for j = 1 : m # for every input channel + ## initial conditions + x = zeros (n, 1); + u = zeros (m, 1); + u(j) = 1; - if (stable) - stairs (t, [y(:, k, j), yfinal(k, j) * ones(l_t, 1)]); - else - stairs (t, y(:, k, j)); - endif + ## simulation + for k = 1 : l_t + y(k, :, j) = C * x + D * u; + x_arr(k, :, j) = x; + x = F * x + G * u; + endfor + endfor - grid ("on"); +endfunction - if (k == 1 && j == 1) - title (str); - endif - if (j == 1) - ylabel (sprintf ("Amplitude %s", outname{k})); - endif +function [y, x_arr] = __impulse_response__ (sys, sys_dt, t) - endfor - endfor + [~, B] = ssdata (sys); + [F, G, C, D, dt] = ssdata (sys_dt); # system must be proper + dt = abs (dt); # use 1 second if tsam is unspecified (-1) + discrete = ! isct (sys); - xlabel ("Time [s]"); + n = rows (F); # number of states + m = columns (G); # number of inputs + p = rows (C); # number of outputs + l_t = length (t); - else # continuous system - for k = 1 : p - for j = 1 : cols + ## preallocate memory + y = zeros (l_t, p, m); + x_arr = zeros (l_t, n, m); - subplot (p, cols, (k-1)*cols+j); + for j = 1 : m # for every input channel + ## initial conditions + u = zeros (m, 1); + u(j) = 1; - if (stable) - plot (t, [y(:, k, j), yfinal(k, j) * ones(l_t, 1)]); - else - plot (t, y(:, k, j)); - endif + if (discrete) + x = zeros (n, 1); # zero by definition + y(1, :, j) = D * u / dt; + x_arr(1, :, j) = x; + x = G * u / dt; + else + x = B * u; # B, not G! + y(1, :, j) = C * x; + x_arr(1, :, j) = x; + x = F * x; + endif - grid ("on"); + ## simulation + for k = 2 : l_t + y (k, :, j) = C * x; + x_arr(k, :, j) = x; + x = F * x; + endfor + endfor - if (k == 1 && j == 1) - title (str); - endif - - if (j == 1) - ylabel (sprintf ("Amplitude %s", outname{k})); - endif - - endfor - endfor - - xlabel ("Time [s]"); - - endif + if (discrete) + y *= dt; + x_arr *= dt; endif endfunction -function [tfinal, dt] = __sim_horizon__ (A, discrete, tfinal, Ts) +function [tfinal, dt] = __sim_horizon__ (sys, tfinal, Ts) ## code based on __stepimp__.m of Kai P. Mueller and A. Scottedward Hodel - TOL = 1.0e-10; # values below TOL are assumed to be zero - N_MIN = 50; # min number of points - N_MAX = 2000; # max number of points - N_DEF = 1000; # default number of points - T_DEF = 10; # default simulation time + TOL = 1.0e-10; # values below TOL are assumed to be zero + N_MIN = 50; # min number of points + N_MAX = 2000; # max number of points + N_DEF = 1000; # default number of points + T_DEF = 10; # default simulation time - n = rows (A); - eigw = eig (A); + ev = pole (sys); + n = length (ev); # number of states/poles + continuous = isct (sys); + discrete = ! continuous; if (discrete) + dt = Ts = abs (get (sys, "tsam")); ## perform bilinear transformation on poles in z for k = 1 : n - pol = eigw(k); + pol = ev(k); if (abs (pol + 1) < TOL) - eigw(k) = 0; + ev(k) = 0; else - eigw(k) = 2 / Ts * (pol - 1) / (pol + 1); + ev(k) = 2 / Ts * (pol - 1) / (pol + 1); endif endfor endif - ## remove poles near zero from eigenvalue array eigw + ## remove poles near zero from eigenvalue array ev nk = n; for k = 1 : n - if (abs (real (eigw(k))) < TOL) - eigw(k) = 0; + if (abs (real (ev(k))) < TOL) + ev(k) = 0; nk -= 1; endif endfor @@ -264,27 +373,27 @@ tfinal = T_DEF; endif - if (! discrete) + if (continuous) dt = tfinal / N_DEF; endif else - eigw = eigw(find (eigw)); - eigw_max = max (abs (eigw)); + ev = ev(find (ev)); + ev_max = max (abs (ev)); - if (! discrete) - dt = 0.2 * pi / eigw_max; + if (continuous) + dt = 0.2 * pi / ev_max; endif if (isempty (tfinal)) - eigw_min = min (abs (real (eigw))); - tfinal = 5.0 / eigw_min; + ev_min = min (abs (real (ev))); + tfinal = 5.0 / ev_min; ## round up yy = 10^(ceil (log10 (tfinal)) - 1); tfinal = yy * ceil (tfinal / yy); endif - if (! discrete) + if (continuous) N = tfinal / dt; if (N < N_MIN) @@ -297,7 +406,7 @@ endif endif - if (! isempty (Ts)) # catch case cont. system with dt specified + if (continuous && ! isempty (Ts)) # catch case cont. system with dt specified dt = Ts; endif Modified: trunk/octave-forge/main/control/inst/step.m =================================================================== --- trunk/octave-forge/main/control/inst/step.m 2012-09-22 10:14:12 UTC (rev 11073) +++ trunk/octave-forge/main/control/inst/step.m 2012-09-22 10:23:23 UTC (rev 11074) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -54,22 +54,35 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 -function [y_r, t_r, x_r] = step (sys, tfinal = [], dt = []) +function [y_r, t_r, x_r] = step2 (varargin) - ## TODO: multiplot feature: step (sys1, "b", sys2, "r", ...) - - if (nargin == 0 || nargin > 3) + if (nargin == 0) print_usage (); endif - [y, t, x] = __time_response__ (sys, "step", ! nargout, tfinal, dt, [], inputname (1)); + if (nargout) + sysname = {}; + else + sys_idx = find (cellfun (@isa, varargin, {"lti"})); + len = length (sys_idx); + sysname = cell (len, 1); + for k = 1 : len + try + sysname{k} = inputname(sys_idx(k)); + catch + sysname{k} = ""; + end_try_catch + endfor + endif + [y, t, x] = __time_response_2__ ("step", varargin, sysname, ! nargout); + if (nargout) - y_r = y; - t_r = t; - x_r = x; + y_r = y{1}; + t_r = t{1}; + x_r = x{1}; endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |