From: <par...@us...> - 2011-06-29 22:01:10
|
Revision: 8370 http://octave.svn.sourceforge.net/octave/?rev=8370&view=rev Author: paramaniac Date: 2011-06-29 22:01:03 +0000 (Wed, 29 Jun 2011) Log Message: ----------- control: use @uref in texinfo strings Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/norm.m trunk/octave-forge/main/control/inst/@ss/__minreal__.m trunk/octave-forge/main/control/inst/@ss/__zero__.m trunk/octave-forge/main/control/inst/care.m trunk/octave-forge/main/control/inst/dare.m trunk/octave-forge/main/control/inst/dlyap.m trunk/octave-forge/main/control/inst/dlyapchol.m trunk/octave-forge/main/control/inst/h2syn.m trunk/octave-forge/main/control/inst/hinfsyn.m trunk/octave-forge/main/control/inst/hsvd.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/lyap.m trunk/octave-forge/main/control/inst/lyapchol.m trunk/octave-forge/main/control/inst/place.m Modified: trunk/octave-forge/main/control/inst/@lti/norm.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/norm.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/@lti/norm.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -20,8 +20,8 @@ ## @deftypefnx {Function File} {[@var{gain}, @var{wpeak}] =} norm (@var{sys}, @var{inf}) ## @deftypefnx {Function File} {[@var{gain}, @var{wpeak}] =} norm (@var{sys}, @var{inf}, @var{tol}) ## Return H-2 or L-inf norm of LTI model. -## Uses SLICOT AB13BD and AB13DD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB13BD and AB13DD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/@ss/__minreal__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__minreal__.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/@ss/__minreal__.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -17,8 +17,8 @@ ## -*- texinfo -*- ## Minimal realization of SS models. The physical meaning of states is lost. -## Uses SLICOT TB01PD and TG01JD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT TB01PD and TG01JD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 Modified: trunk/octave-forge/main/control/inst/@ss/__zero__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__zero__.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/@ss/__zero__.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -17,8 +17,8 @@ ## -*- texinfo -*- ## Transmission zeros of SS object. -## Uses SLICOT AB08ND by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB08ND by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 Modified: trunk/octave-forge/main/control/inst/care.m =================================================================== --- trunk/octave-forge/main/control/inst/care.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/care.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -21,8 +21,8 @@ ## @deftypefnx {Function File} {[@var{x}, @var{l}, @var{g}] =} care (@var{a}, @var{b}, @var{q}, @var{r}, @var{[]}, @var{e}) ## @deftypefnx {Function File} {[@var{x}, @var{l}, @var{g}] =} care (@var{a}, @var{b}, @var{q}, @var{r}, @var{s}, @var{e}) ## Solve continuous-time algebraic Riccati equation (ARE). -## Uses SLICOT SB02OD and SG02AD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB02OD and SG02AD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/dare.m =================================================================== --- trunk/octave-forge/main/control/inst/dare.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/dare.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -21,8 +21,8 @@ ## @deftypefnx {Function File} {[@var{x}, @var{l}, @var{g}] =} dare (@var{a}, @var{b}, @var{q}, @var{r}, @var{[]}, @var{e}) ## @deftypefnx {Function File} {[@var{x}, @var{l}, @var{g}] =} dare (@var{a}, @var{b}, @var{q}, @var{r}, @var{s}, @var{e}) ## Solve discrete-time algebraic Riccati equation (ARE). -## Uses SLICOT SB02OD and SG02AD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB02OD and SG02AD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/dlyap.m =================================================================== --- trunk/octave-forge/main/control/inst/dlyap.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/dlyap.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -20,8 +20,8 @@ ## @deftypefnx{Function File} {@var{x} =} dlyap (@var{a}, @var{b}, @var{c}) ## @deftypefnx{Function File} {@var{x} =} dlyap (@var{a}, @var{b}, @var{[]}, @var{e}) ## Solve discrete-time Lyapunov or Sylvester equations. -## Uses SLICOT SB03MD, SB04QD and SG03AD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB03MD, SB04QD and SG03AD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Equations} ## @example Modified: trunk/octave-forge/main/control/inst/dlyapchol.m =================================================================== --- trunk/octave-forge/main/control/inst/dlyapchol.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/dlyapchol.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -19,8 +19,8 @@ ## @deftypefn{Function File} {@var{u} =} dlyapchol (@var{a}, @var{b}) ## @deftypefnx{Function File} {@var{u} =} dlyapchol (@var{a}, @var{b}, @var{e}) ## Compute Cholesky factor of discrete-time Lyapunov equations. -## Uses SLICOT SB03OD and SG03BD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB03OD and SG03BD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Equations} ## @example Modified: trunk/octave-forge/main/control/inst/h2syn.m =================================================================== --- trunk/octave-forge/main/control/inst/h2syn.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/h2syn.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -18,8 +18,8 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}] =} h2syn (@var{P}, @var{nmeas}, @var{ncon}) ## H-2 control synthesis for LTI plant. -## Uses SLICOT SB10HD and SB10ED by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB10HD and SB10ED by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/hinfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/hinfsyn.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/hinfsyn.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -19,8 +19,8 @@ ## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}] =} hinfsyn (@var{P}, @var{nmeas}, @var{ncon}) ## @deftypefnx{Function File} {[@var{K}, @var{N}, @var{gamma}] =} hinfsyn (@var{P}, @var{nmeas}, @var{ncon}, @var{gmax}) ## H-infinity control synthesis for LTI plant. -## Uses SLICOT SB10FD and SB10DD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB10FD and SB10DD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/hsvd.m =================================================================== --- trunk/octave-forge/main/control/inst/hsvd.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/hsvd.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -20,8 +20,8 @@ ## @deftypefnx{Function File} {@var{hsv} =} hsvd (@var{sys}, @var{"offset"}, @var{alpha}) ## Hankel singular values of the stable part of an LTI model. If no output arguments are ## given, the Hankel singular values are displayed in a plot. -## Uses SLICOT AB13AD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB13AD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/isctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/isctrb.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/isctrb.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -23,8 +23,8 @@ ## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{a}, @var{b}, @var{[]}, @var{tol}) ## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{a}, @var{b}, @var{e}, @var{tol}) ## Logical check for system controllability. -## Uses SLICOT AB01OD and TG01HD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB01OD and TG01HD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/isdetectable.m =================================================================== --- trunk/octave-forge/main/control/inst/isdetectable.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/isdetectable.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -28,8 +28,8 @@ ## @deftypefnx {Function File} {@var{bool} =} isdetectable (@var{a}, @var{c}, @var{e}, @var{tol}, @var{dflg}) ## Logical test for system detectability. ## All unstable modes must be observable or all unobservable states must be stable. -## Uses SLICOT AB01OD and TG01HD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB01OD and TG01HD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/isobsv.m =================================================================== --- trunk/octave-forge/main/control/inst/isobsv.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/isobsv.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -23,8 +23,8 @@ ## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{a}, @var{c}, @var{[]}, @var{tol}) ## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{a}, @var{c}, @var{e}, @var{tol}) ## Logical check for system observability. -## Uses SLICOT AB01OD and TG01HD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB01OD and TG01HD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/isstabilizable.m =================================================================== --- trunk/octave-forge/main/control/inst/isstabilizable.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/isstabilizable.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -28,8 +28,8 @@ ## @deftypefnx {Function File} {@var{bool} =} isstabilizable (@var{a}, @var{b}, @var{e}, @var{tol}, @var{dflg}) ## Logical check for system stabilizability. ## All unstable modes must be controllable or all uncontrollable states must be stable. -## Uses SLICOT AB01OD and TG01HD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT AB01OD and TG01HD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Inputs} ## @table @var Modified: trunk/octave-forge/main/control/inst/lyap.m =================================================================== --- trunk/octave-forge/main/control/inst/lyap.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/lyap.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -20,8 +20,8 @@ ## @deftypefnx{Function File} {@var{x} =} lyap (@var{a}, @var{b}, @var{c}) ## @deftypefnx{Function File} {@var{x} =} lyap (@var{a}, @var{b}, @var{[]}, @var{e}) ## Solve continuous-time Lyapunov or Sylvester equations. -## Uses SLICOT SB03MD, SB04MD and SG03AD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB03MD, SB04MD and SG03AD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Equations} ## @example Modified: trunk/octave-forge/main/control/inst/lyapchol.m =================================================================== --- trunk/octave-forge/main/control/inst/lyapchol.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/lyapchol.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -19,8 +19,8 @@ ## @deftypefn{Function File} {@var{u} =} lyapchol (@var{a}, @var{b}) ## @deftypefnx{Function File} {@var{u} =} lyapchol (@var{a}, @var{b}, @var{e}) ## Compute Cholesky factor of continuous-time Lyapunov equations. -## Uses SLICOT SB03OD and SG03BD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB03OD and SG03BD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @strong{Equations} ## @example Modified: trunk/octave-forge/main/control/inst/place.m =================================================================== --- trunk/octave-forge/main/control/inst/place.m 2011-06-29 21:52:06 UTC (rev 8369) +++ trunk/octave-forge/main/control/inst/place.m 2011-06-29 22:01:03 UTC (rev 8370) @@ -23,8 +23,8 @@ ## Pole assignment for a given matrix pair (@var{A},@var{B}) such that @code{p = eig (A-B*F)}. ## If parameter @var{alpha} is specified, poles with real parts (continuous-time) ## or moduli (discrete-time) below @var{alpha} are left untouched. -## Uses SLICOT SB01BD by courtesy of NICONET e.V. -## <http://www.slicot.org> +## Uses SLICOT SB01BD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} ## ## @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...> - 2011-07-05 19:08:07
|
Revision: 8375 http://octave.svn.sourceforge.net/octave/?rev=8375&view=rev Author: paramaniac Date: 2011-07-05 19:08:00 +0000 (Tue, 05 Jul 2011) Log Message: ----------- control: add texinfo string to ssdata, use circle for zeros in pzmap Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/ssdata.m trunk/octave-forge/main/control/inst/pzmap.m Modified: trunk/octave-forge/main/control/inst/@lti/ssdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/ssdata.m 2011-07-04 13:02:03 UTC (rev 8374) +++ trunk/octave-forge/main/control/inst/@lti/ssdata.m 2011-07-05 19:08:00 UTC (rev 8375) @@ -18,6 +18,29 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}] =} ssdata (@var{sys}) ## Access state-space model data. +## Argument @var{sys} is not limited to state-space models. +## If @var{sys} is not a state-space model, it is converted automatically. +## +## @strong{Inputs} +## @table @var +## @item sys +## Any type of LTI model. +## @end table +## +## @strong{Outputs} +## @table @var +## @item a +## State transition matrix (n-by-n). +## @item b +## Input matrix (n-by-m). +## @item c +## Measurement matrix (p-by-n). +## @item d +## Feedthrough matrix (p-by-m). +## @item tsam +## Sampling time in seconds. If @var{sys} is a continuous-time model, +## a zero is returned. +## @end table ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/pzmap.m =================================================================== --- trunk/octave-forge/main/control/inst/pzmap.m 2011-07-04 13:02:03 UTC (rev 8374) +++ trunk/octave-forge/main/control/inst/pzmap.m 2011-07-05 19:08:00 UTC (rev 8375) @@ -28,7 +28,6 @@ function [pol_r, zer_r] = pzmap (sys) ## TODO: multiplot feature: pzmap (sys1, "b", sys2, "r", ...) - ## TODO: use better symbols for poles and zeros, fltk backend might be helpful if (nargin != 1) print_usage (); @@ -47,7 +46,7 @@ zer_re = real (zer); zer_im = imag (zer); - plot (pol_re, pol_im, "xb", zer_re, zer_im, "sr") + plot (pol_re, pol_im, "xb", zer_re, zer_im, "or") grid ("on") title (["Pole-Zero Map of ", inputname(1)]) xlabel ("Real Axis") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-07-24 20:36:16
|
Revision: 8406 http://octave.svn.sourceforge.net/octave/?rev=8406&view=rev Author: paramaniac Date: 2011-07-24 20:36:09 +0000 (Sun, 24 Jul 2011) Log Message: ----------- control: minor improvements Modified Paths: -------------- trunk/octave-forge/main/control/inst/h2syn.m trunk/octave-forge/main/control/inst/hinfsyn.m trunk/octave-forge/main/control/inst/hsvd.m Modified: trunk/octave-forge/main/control/inst/h2syn.m =================================================================== --- trunk/octave-forge/main/control/inst/h2syn.m 2011-07-24 06:25:59 UTC (rev 8405) +++ trunk/octave-forge/main/control/inst/h2syn.m 2011-07-24 20:36:09 UTC (rev 8406) @@ -16,7 +16,7 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}] =} h2syn (@var{P}, @var{nmeas}, @var{ncon}) +## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}, @var{rcond}] =} h2syn (@var{P}, @var{nmeas}, @var{ncon}) ## H-2 control synthesis for LTI plant. ## Uses SLICOT SB10HD and SB10ED by courtesy of ## @uref{http://www.slicot.org, NICONET e.V.} Modified: trunk/octave-forge/main/control/inst/hinfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/hinfsyn.m 2011-07-24 06:25:59 UTC (rev 8405) +++ trunk/octave-forge/main/control/inst/hinfsyn.m 2011-07-24 20:36:09 UTC (rev 8406) @@ -16,8 +16,8 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}] =} hinfsyn (@var{P}, @var{nmeas}, @var{ncon}) -## @deftypefnx{Function File} {[@var{K}, @var{N}, @var{gamma}] =} hinfsyn (@var{P}, @var{nmeas}, @var{ncon}, @var{gmax}) +## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}, @var{rcond}] =} hinfsyn (@var{P}, @var{nmeas}, @var{ncon}) +## @deftypefnx{Function File} {[@var{K}, @var{N}, @var{gamma}, @var{rcond}] =} hinfsyn (@var{P}, @var{nmeas}, @var{ncon}, @var{gmax}) ## H-infinity control synthesis for LTI plant. ## Uses SLICOT SB10FD and SB10DD by courtesy of ## @uref{http://www.slicot.org, NICONET e.V.} Modified: trunk/octave-forge/main/control/inst/hsvd.m =================================================================== --- trunk/octave-forge/main/control/inst/hsvd.m 2011-07-24 06:25:59 UTC (rev 8405) +++ trunk/octave-forge/main/control/inst/hsvd.m 2011-07-24 20:36:09 UTC (rev 8406) @@ -58,7 +58,7 @@ hsv_r = hsv; else bar ((1:ns) + (rows (a) - ns), hsv); - title ("Hankel Singular Values of Stable Part"); + title (["Hankel Singular Values of Stable Part of ", inputname(1)]); xlabel ("State"); ylabel ("State Energy"); grid ("on"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-08-06 18:56:09
|
Revision: 8443 http://octave.svn.sourceforge.net/octave/?rev=8443&view=rev Author: paramaniac Date: 2011-08-06 18:56:03 +0000 (Sat, 06 Aug 2011) Log Message: ----------- control: improve texinfo strings Modified Paths: -------------- trunk/octave-forge/main/control/inst/@frd/frd.m trunk/octave-forge/main/control/inst/@lti/isct.m trunk/octave-forge/main/control/inst/@lti/isdt.m trunk/octave-forge/main/control/inst/@lti/size.m trunk/octave-forge/main/control/inst/@ss/ss.m trunk/octave-forge/main/control/inst/@tf/tf.m trunk/octave-forge/main/control/inst/ctrb.m trunk/octave-forge/main/control/inst/dss.m trunk/octave-forge/main/control/inst/obsv.m Modified: trunk/octave-forge/main/control/inst/@frd/frd.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/frd.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/@frd/frd.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -25,7 +25,8 @@ ## @strong{Inputs} ## @table @var ## @item sys -## LTI model. If second argument @var{w} is omitted, the interesting +## LTI model to be converted to frequency response data. +## If second argument @var{w} is omitted, the interesting ## frequency range is calculated by the zeros and poles of @var{sys}. ## @item H ## Frequency response array (p-by-m-by-lw). In the SISO case, Modified: trunk/octave-forge/main/control/inst/@lti/isct.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isct.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/@lti/isct.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -18,6 +18,20 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isct (@var{sys}) ## Determine whether LTI model is a continuous-time system. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI system. +## @end table +## +## @strong{Outputs} +## @table @var +## @item bool = 0 +## @var{sys} is a discrete-time system. +## @item bool = 1 +## @var{sys} is a continuous-time system or a static gain. +## @end table ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> @@ -32,4 +46,4 @@ bool = (ltisys.tsam == 0 || ltisys.tsam == -2); -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/@lti/isdt.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/isdt.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/@lti/isdt.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -18,6 +18,20 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isdt (@var{sys}) ## Determine whether LTI model is a discrete-time system. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI system. +## @end table +## +## @strong{Outputs} +## @table @var +## @item bool = 0 +## @var{sys} is a continuous-time system. +## @item bool = 1 +## @var{sys} is a discrete-time system or a static gain. +## @end table ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> @@ -32,4 +46,4 @@ bool = (ltisys.tsam != 0); -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/@lti/size.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/size.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/@lti/size.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -16,54 +16,76 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{nvec} =} size (@var{ltisys}) -## @deftypefnx {Function File} {@var{n} =} size (@var{ltisys}, @var{idx}) -## @deftypefnx {Function File} {[@var{ny}, @var{nu}] =} size (@var{ltisys}) +## @deftypefn {Function File} {@var{nvec} =} size (@var{sys}) +## @deftypefnx {Function File} {@var{n} =} size (@var{sys}, @var{dim}) +## @deftypefnx {Function File} {[@var{p}, @var{m}] =} size (@var{sys}) ## LTI model size, i.e. number of outputs and inputs. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI system. +## @item dim +## If given a second argument, @command{size} will return the size of the +## corresponding dimension. +## @end table +## +## @strong{Outputs} +## @table @var +## @item nvec +## Row vector. The first element is the number of outputs (rows) and the second +## element the number of inputs (columns). +## @item n +## Scalar value. The size of the dimension @var{dim}. +## @item p +## Number of outputs. +## @item m +## Number of inputs. +## @end table ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.1 +## Version: 0.2 -function [n, varargout] = size (ltisys, idx = 0) +function [n, varargout] = size (ltisys, dim = 0) if (nargin > 2) print_usage (); endif - ny = numel (ltisys.outname); # WARNING: system matrices may change without - nu = numel (ltisys.inname); # being noticed by the i/o names! + p = numel (ltisys.outname); # WARNING: system matrices may change without + m = numel (ltisys.inname); # being noticed by the i/o names! - switch (idx) + switch (dim) case 0 switch (nargout) case 0 - if (ny == 1) + if (p == 1) stry = ""; else stry = "s"; endif - if (nu == 1) + if (m == 1) stru = ""; else stru = "s"; endif disp (sprintf ("LTI model with %d output%s and %d input%s.", ny, stry, nu, stru)); case 1 - n = [ny, nu]; + n = [p, m]; case 2 - n = ny; - varargout{1} = nu; + n = p; + varargout{1} = m; otherwise print_usage (); endswitch case 1 - n = ny; + n = p; case 2 - n = nu; + n = m; otherwise print_usage (); endswitch -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/@ss/ss.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/ss.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/@ss/ss.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -26,6 +26,8 @@ ## ## @strong{Inputs} ## @table @var +## @item sys +## LTI model to be converted to state-space. ## @item a ## State transition matrix (n-by-n). ## @item b Modified: trunk/octave-forge/main/control/inst/@tf/tf.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/tf.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/@tf/tf.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -25,6 +25,8 @@ ## ## @strong{Inputs} ## @table @var +## @item sys +## LTI model to be converted to transfer function. ## @item num ## Numerator or cell of numerators. Each numerator must be a row vector ## containing the exponents of the polynomial in descending order. Modified: trunk/octave-forge/main/control/inst/ctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/ctrb.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/ctrb.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -19,7 +19,36 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{co} =} ctrb (@var{sys}) ## @deftypefnx {Function File} {@var{co} =} ctrb (@var{a}, @var{b}) +## Return controllability matrix. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model. +## @item a +## State transition matrix (n-by-n). +## @item b +## Input matrix (n-by-m). +## @end table +## +## @strong{Outputs} +## @table @var +## @item co ## Controllability matrix. +## @end table +## +## @strong{Equation} +## @iftex +## @tex +## $$ C_o = [ B AB A^2B \ldots A^{n-1}B ] $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## 2 n-1 +## Co = [ B AB A B ... A B ] +## @end example +## @end ifinfo ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/dss.m =================================================================== --- trunk/octave-forge/main/control/inst/dss.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/dss.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -24,6 +24,8 @@ ## ## @strong{Inputs} ## @table @var +## @item sys +## LTI model to be converted to state-space. ## @item a ## State transition matrix (n-by-n). ## @item b @@ -85,4 +87,4 @@ ## ## but this would break compatibility to a widespread ## commercial implementation of the octave language. -## There's no way to tell e and d apart if n = m = p. \ No newline at end of file +## There's no way to tell e and d apart if n = m = p. Modified: trunk/octave-forge/main/control/inst/obsv.m =================================================================== --- trunk/octave-forge/main/control/inst/obsv.m 2011-08-06 12:32:14 UTC (rev 8442) +++ trunk/octave-forge/main/control/inst/obsv.m 2011-08-06 18:56:03 UTC (rev 8443) @@ -19,7 +19,45 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{ob} =} obsv (@var{sys}) ## @deftypefnx {Function File} {@var{ob} =} obsv (@var{a}, @var{c}) +## Return observability matrix. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI model. +## @item a +## State transition matrix (n-by-n). +## @item c +## Measurement matrix (p-by-n). +## @end table +## +## @strong{Outputs} +## @table @var +## @item co ## Observability matrix. +## @end table +## +## @strong{Equation} +## @iftex +## @tex +## $$ O_b = \left[ \matrix{ C \cr +## CA \cr +## CA^2 \cr +## \vdots \cr +## CA^{n-1} } \right ] $$ +## @end tex +## @end iftex +## @ifinfo +## @example +## @group +## | C | +## | CA | +## Ob = | CA^2 | +## | ... | +## | CA^(n-1) | +## @end group +## @end example +## @end ifinfo ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-09-03 19:42:11
|
Revision: 8489 http://octave.svn.sourceforge.net/octave/?rev=8489&view=rev Author: paramaniac Date: 2011-09-03 19:42:05 +0000 (Sat, 03 Sep 2011) Log Message: ----------- control: add d2c (incomplete) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@ss/__c2d__.m trunk/octave-forge/main/control/inst/@tf/__c2d__.m trunk/octave-forge/main/control/inst/ltimodels.m Added Paths: ----------- trunk/octave-forge/main/control/inst/@frd/__d2c__.m trunk/octave-forge/main/control/inst/@lti/d2c.m trunk/octave-forge/main/control/inst/@ss/__d2c__.m trunk/octave-forge/main/control/inst/@tf/__d2c__.m Added: trunk/octave-forge/main/control/inst/@frd/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/__d2c__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@frd/__d2c__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,31 @@ +## Copyright (C) 2011 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 -*- +## Convert the discrete FRD object into its continuous-time equivalent. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = __d2c__ (sys, tsam, method = "zoh") + + error ("frd: d2c: conversion not possible"); + + ## NOTE: changing just the sampling time wouldn't make sense here + +endfunction \ No newline at end of file Added: trunk/octave-forge/main/control/inst/@lti/d2c.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/d2c.m (rev 0) +++ trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,45 @@ +## Copyright (C) 2011 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{sys} =} d2c (@var{sys}) +## @deftypefnx {Function File} {@var{sys} =} d2c (@var{sys}, @var{method}) +## Convert the discrete lti model into its continuous-time equivalent. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = d2c (sys, method = "std") + + if (nargin == 0 || nargin > 2) + print_usage (); + endif + + if (! isa (sys, "lti")) + error ("d2c: first argument is not an lti model"); + endif + + if (! ischar (method)) + error ("c2d: second argument is not a string"); + endif + + sys = __d2c__ (sys, sys.tsam, method); + sys.tsam = 0; + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@ss/__c2d__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2011-09-03 18:50:35 UTC (rev 8488) +++ trunk/octave-forge/main/control/inst/@ss/__c2d__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -16,11 +16,11 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## Convert the continuous SS model into its discrete time equivalent. +## Convert the continuous SS model into its discrete-time equivalent. ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1 +## Version: 0.2 function sys = __c2d__ (sys, tsam, method = "zoh") @@ -58,7 +58,7 @@ [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, 2/tsam, false); otherwise - error ("ss: c2d: %s is an invalid method", method); + error ("ss: c2d: %s is an invalid or missing method", method); endswitch Added: trunk/octave-forge/main/control/inst/@ss/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__d2c__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@ss/__d2c__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,65 @@ +## Copyright (C) 2011 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 -*- +## Convert the discrete SS model into its continuous-time equivalent. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = __d2c__ (sys, tsam, method = "zoh") + + switch (method) + case {"zoh", "std"} + if (! isempty (sys.e)) + if (rcond (sys.e) < eps) + error ("ss: d2c: zero-order hold method requires proper system"); + else + sys.a = sys.e \ sys.a; + sys.b = sys.e \ sys.b; + sys.e = []; # require ordinary state-space model + endif + endif + + [n, m] = size (sys.b); # n: states, m: inputs + + ## TODO: use SLICOT MB05OD + tmp = expm ([sys.a*tsam, sys.b*tsam; zeros(m, n+m)]); + + sys.a = tmp (1:n, 1:n); # F + sys.b = tmp (1:n, n+(1:m)); # G + + case {"tustin", "bilin"} + if (! isempty (sys.e)) + if (rcond (sys.e) < eps) + error ("ss: d2c: tustin method requires proper system"); + else + sys.a = sys.e \ sys.a; + sys.b = sys.e \ sys.b; + sys.e = []; # require ordinary state-space model + endif + endif + + [sys.a, sys.b, sys.c, sys.d] = slab04md (sys.a, sys.b, sys.c, sys.d, 1, 2/tsam, true); + + otherwise + error ("ss: d2c: %s is an invalid or missing method", method); + + endswitch + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/@tf/__c2d__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__c2d__.m 2011-09-03 18:50:35 UTC (rev 8488) +++ trunk/octave-forge/main/control/inst/@tf/__c2d__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -16,7 +16,7 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## Convert the continuous TF model into its discrete time equivalent. +## Convert the continuous TF model into its discrete-time equivalent. ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 Added: trunk/octave-forge/main/control/inst/@tf/__d2c__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__d2c__.m (rev 0) +++ trunk/octave-forge/main/control/inst/@tf/__d2c__.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -0,0 +1,29 @@ +## Copyright (C) 2011 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 -*- +## Convert the discrete TF model into its continuous-time equivalent. + +## Author: Lukas Reichlin <luk...@gm...> +## Created: September 2011 +## Version: 0.1 + +function sys = __d2c__ (sys, tsam, method = "zoh") + + error ("tf: d2c: not implemented yet"); + +endfunction \ No newline at end of file Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2011-09-03 18:50:35 UTC (rev 8488) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2011-09-03 19:42:05 UTC (rev 8489) @@ -1297,3 +1297,25 @@ %! Me = [Ae, Be; Ce, De]; %! %!assert (Mo, Me, 1e-4); + + +## bilinear transformation +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "tustin"), "tustin")); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-09-06 06:03:16
|
Revision: 8505 http://octave.svn.sourceforge.net/octave/?rev=8505&view=rev Author: paramaniac Date: 2011-09-06 06:03:10 +0000 (Tue, 06 Sep 2011) Log Message: ----------- control: improve argument checking, add a test Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/c2d.m trunk/octave-forge/main/control/inst/@lti/d2c.m trunk/octave-forge/main/control/inst/ltimodels.m Modified: trunk/octave-forge/main/control/inst/@lti/c2d.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/c2d.m 2011-09-05 21:03:51 UTC (rev 8504) +++ trunk/octave-forge/main/control/inst/@lti/c2d.m 2011-09-06 06:03:10 UTC (rev 8505) @@ -24,7 +24,7 @@ ## @strong{Inputs} ## @table @var ## @item sys -## Continuous-time LTI model. +## Continuous-time LTI model. Only state-space models have been implemented so far. ## @item tsam ## Sampling time in seconds. ## @item method @@ -73,6 +73,10 @@ error ("c2d: third argument is not a string"); endif + if (! issample (w0, 0)) + error ("c2d: fourth argument is not a valid pre-warping frequency"); + endif + sys = __c2d__ (sys, tsam, lower (method), w0); sys.tsam = tsam; Modified: trunk/octave-forge/main/control/inst/@lti/d2c.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-09-05 21:03:51 UTC (rev 8504) +++ trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-09-06 06:03:10 UTC (rev 8505) @@ -24,7 +24,7 @@ ## @strong{Inputs} ## @table @var ## @item sys -## Discrete-time LTI model. +## Discrete-time LTI model. Only state-space models have been implemented so far. ## @item method ## Optional conversion method. If not specified, default method @var{"zoh"} ## is taken. @@ -67,6 +67,10 @@ error ("d2c: second argument is not a string"); endif + if (! issample (w0, 0)) + error ("d2c: third argument is not a valid pre-warping frequency"); + endif + sys = __d2c__ (sys, sys.tsam, lower (method), w0); sys.tsam = 0; Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2011-09-05 21:03:51 UTC (rev 8504) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2011-09-06 06:03:10 UTC (rev 8505) @@ -1346,3 +1346,26 @@ %! %!assert (Mo, Me, 1e-4); + +## bilinear transformation with pre-warping +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "prewarp", 1000), "prewarp", 1000)); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-09-18 07:27:47
|
Revision: 8549 http://octave.svn.sourceforge.net/octave/?rev=8549&view=rev Author: paramaniac Date: 2011-09-18 07:27:40 +0000 (Sun, 18 Sep 2011) Log Message: ----------- control: add more comments to constructors Modified Paths: -------------- trunk/octave-forge/main/control/inst/@frd/frd.m trunk/octave-forge/main/control/inst/@ss/ss.m trunk/octave-forge/main/control/inst/@tf/tf.m Modified: trunk/octave-forge/main/control/inst/@frd/frd.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/frd.m 2011-09-17 05:34:35 UTC (rev 8548) +++ trunk/octave-forge/main/control/inst/@frd/frd.m 2011-09-18 07:27:40 UTC (rev 8549) @@ -100,7 +100,7 @@ otherwise # default case argc = numel (varargin); # number of additional arguments after H and w if (issample (varargin{1}, -10)) # sys = frd (H, w, tsam, "prop1", val1, ...) - tsam = varargin{1}; # discrete-time + tsam = varargin{1}; # sampling time, could be 0 as well argc--; # tsam is not a property-value pair if (argc > 0) # if there are any properties and values ... varargin = varargin(2:end); # remove tsam from property-value list @@ -111,7 +111,7 @@ endswitch [H, w] = __adjust_frd_data__ (H, w); - [p, m] = __frd_dim__ (H, w); + [p, m] = __frd_dim__ (H, w); # determine number of outputs and inputs frdata = struct ("H", H, "w", w); # struct for frd-specific data ltisys = lti (p, m, tsam); # parent class for general lti data Modified: trunk/octave-forge/main/control/inst/@ss/ss.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/ss.m 2011-09-17 05:34:35 UTC (rev 8548) +++ trunk/octave-forge/main/control/inst/@ss/ss.m 2011-09-18 07:27:40 UTC (rev 8549) @@ -101,51 +101,51 @@ ## inferiorto ("frd"); superiorto ("zpk", "tf", "double"); - argc = 0; # initialize argument count - tsam = 0; # initialize sampling time + argc = 0; # initialize argument count + tsam = 0; # initialize sampling time if (nargin == 1) - if (isa (a, "ss")) # already in ss form + if (isa (a, "ss")) # already in ss form sys = ss (sssys) sys = a; return; - elseif (isa (a, "lti")) # another lti object + elseif (isa (a, "lti")) # another lti object sys = ss (sys) [sys, alti] = __sys2ss__ (a); - sys.lti = alti; # preserve lti properties + sys.lti = alti; # preserve lti properties return; - elseif (is_real_matrix (a)) # static gain sys = ss (5) + elseif (is_real_matrix (a)) # static gain sys = ss (5), sys = ss (matrix) d = a; a = []; else print_usage (); endif - elseif (nargin > 4) # default case sys = ss (a, b, c, d, "prop1", val1, ...) - argc = numel (varargin); # number of additional arguments after d - if (issample (varargin{1}, -10)) # sys = ss (a, b, c, d, tsam, "prop1, "val1", ...) - tsam = varargin{1}; - argc--; - if (argc > 0) - varargin = varargin(2:end); + elseif (nargin > 4) # default case sys = ss (a, b, c, d, "prop1", val1, ...) + argc = numel (varargin); # number of additional arguments after d + if (issample (varargin{1}, -10)) # sys = ss (a, b, c, d, tsam, "prop1, "val1", ...) + tsam = varargin{1}; # sampling time, could be 0 as well + argc--; # tsam is not a property-value pair + if (argc > 0) # if there are any properties and values ... + varargin = varargin(2:end); # remove tsam from property-value list endif endif - endif # nothing to do for ss (), ss (a, b), ss (a, b, c), ss (a, b, c, d) + endif # nothing to do for ss (), ss (a, b), ss (a, b, c), ss (a, b, c, d) [a, b, c, d, tsam] = __adjust_ss_data__ (a, b, c, d, tsam); - [p, m, n] = __ss_dim__ (a, b, c, d); + [p, m, n] = __ss_dim__ (a, b, c, d); # determine number of outputs, inputs and states - stname = repmat ({""}, n, 1); + stname = repmat ({""}, n, 1); # cell with empty state names ssdata = struct ("a", a, "b", b, "c", c, "d", d, "e", [], "stname", {stname}, - "scaled", false); + "scaled", false); # struct for ss-specific data - ltisys = lti (p, m, tsam); + ltisys = lti (p, m, tsam); # parent class for general lti data - sys = class (ssdata, "ss", ltisys); + sys = class (ssdata, "ss", ltisys); # create ss object - if (argc > 0) - sys = set (sys, varargin{:}); + if (argc > 0) # if there are any properties and values, ... + sys = set (sys, varargin{:}); # use the general set function endif endfunction Modified: trunk/octave-forge/main/control/inst/@tf/tf.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/tf.m 2011-09-17 05:34:35 UTC (rev 8548) +++ trunk/octave-forge/main/control/inst/@tf/tf.m 2011-09-18 07:27:40 UTC (rev 8549) @@ -84,28 +84,28 @@ ## inferiorto ("frd", "ss", "zpk"); # error if de-commented. bug in octave? superiorto ("double"); - argc = 0; + argc = 0; # initialize argument count switch (nargin) - case 0 - tsam = -2; - tfvar = "x"; # undefined + case 0 # sys = tf () + tsam = -2; # undefined sampling time + tfvar = "x"; # undefined transfer function variable case 1 - if (isa (num, "tf")) # already in tf form + if (isa (num, "tf")) # already in tf form sys = tf (tfsys) sys = num; return; - elseif (isa (num, "lti")) # another lti object + elseif (isa (num, "lti")) # another lti object sys = tf (sys) [sys, numlti] = __sys2tf__ (num); sys.lti = numlti; # preserve lti properties return; - elseif (is_real_matrix (num)) # static gain + elseif (is_real_matrix (num)) # static gain sys = tf (4), sys = tf (matrix) num = num2cell (num); num = __vec2tfpoly__ (num); [p, m] = size (num); - den = tfpolyones (p, m); - tsam = -2; - tfvar = "x"; # undefined + den = tfpolyones (p, m); # denominators are all 1 + tsam = -2; # undefined sampling time + tfvar = "x"; # undefined transfer function variable elseif (ischar (num)) # s = tf ("s") tfvar = num; num = __vec2tfpoly__ ([1, 0]); @@ -128,44 +128,39 @@ tsam = 0; endif - otherwise # default case + otherwise # default case sys = tf (num, den, ...) num = __vec2tfpoly__ (num); den = __vec2tfpoly__ (den); - argc = numel (varargin); - + argc = numel (varargin); # number of additional arguments after num and den if (issample (varargin{1}, -10)) # sys = tf (num, den, tsam, "prop1", val1, ...) - tsam = varargin{1}; - argc--; - + tsam = varargin{1}; # sampling time, could be 0 as well + argc--; # tsam is not a property-value pair if (tsam == 0) tfvar = "s"; else tfvar = "z"; endif - - if (argc > 0) - varargin = varargin(2:end); + if (argc > 0) # if there are any properties and values ... + varargin = varargin(2:end); # remove tsam from property-value list endif else # sys = tf (num, den, "prop1", val1, ...) - tsam = 0; + tsam = 0; # continuous-time tfvar = "s"; endif - endswitch + [p, m] = __tf_dim__ (num, den); # determine number of outputs and inputs - [p, m] = __tf_dim__ (num, den); - tfdata = struct ("num", {num}, "den", {den}, - "tfvar", tfvar); + "tfvar", tfvar); # struct for tf-specific data - ltisys = lti (p, m, tsam); + ltisys = lti (p, m, tsam); # parent class for general lti data - sys = class (tfdata, "tf", ltisys); + sys = class (tfdata, "tf", ltisys); # create tf object - if (argc > 0) - sys = set (sys, varargin{:}); + if (argc > 0) # if there are any properties and values, ... + sys = set (sys, varargin{:}); # use the general set function endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-09-19 14:05:43
|
Revision: 8566 http://octave.svn.sourceforge.net/octave/?rev=8566&view=rev Author: paramaniac Date: 2011-09-19 14:05:34 +0000 (Mon, 19 Sep 2011) Log Message: ----------- control: improve texinfo help strings, fix a bug (thanks to Bernhard Weller) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/tfdata.m trunk/octave-forge/main/control/inst/@tf/__get__.m trunk/octave-forge/main/control/inst/@tf/tf.m Modified: trunk/octave-forge/main/control/inst/@lti/tfdata.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/tfdata.m 2011-09-19 11:40:51 UTC (rev 8565) +++ trunk/octave-forge/main/control/inst/@lti/tfdata.m 2011-09-19 14:05:34 UTC (rev 8566) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -19,11 +19,34 @@ ## @deftypefn {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys}) ## @deftypefnx {Function File} {[@var{num}, @var{den}, @var{tsam}] =} tfdata (@var{sys}, @var{"tfpoly"}) ## Access transfer function data. +## Argument @var{sys} is not limited to transfer function models. +## If @var{sys} is not a transfer function, it is converted automatically. +## +## @strong{Inputs} +## @table @var +## @item sys +## Any type of LTI model. +## @end table +## +## @strong{Outputs} +## @table @var +## @item num +## Cell of numerator(s). Each numerator is a row vector +## containing the coefficients of the polynomial in descending powers of +## the transfer function variable. +## @item den +## Cell of denominator(s). Each denominator is a row vector +## containing the coefficients of the polynomial in descending powers of +## the transfer function variable. +## @item tsam +## Sampling time in seconds. If @var{sys} is a continuous-time model, +## a zero is returned. +## @end table ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.2 +## Version: 0.3 function [num, den, tsam] = tfdata (sys, rtype = "vector") @@ -36,8 +59,8 @@ tsam = sys.tsam; if (rtype(1) == "v") - num = cellfun ("@tfpoly/get", num, "uniformoutput", false); - den = cellfun ("@tfpoly/get", den, "uniformoutput", false); + num = cellfun (@get, num, "uniformoutput", false); + den = cellfun (@get, den, "uniformoutput", false); endif -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/@tf/__get__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__get__.m 2011-09-19 11:40:51 UTC (rev 8565) +++ trunk/octave-forge/main/control/inst/@tf/__get__.m 2011-09-19 14:05:34 UTC (rev 8566) @@ -26,10 +26,10 @@ switch (prop) # {<internal name>, <user name>} case "num" - val = cellfun ("@tfpoly/get", sys.num, "uniformoutput", false); + val = cellfun (@get, sys.num, "uniformoutput", false); case "den" - val = cellfun ("@tfpoly/get", sys.den, "uniformoutput", false); + val = cellfun (@get, sys.den, "uniformoutput", false); case {"tfvar", "variable"} val = sys.tfvar; @@ -38,4 +38,4 @@ error ("tf: get: invalid property name"); endswitch -endfunction \ No newline at end of file +endfunction Modified: trunk/octave-forge/main/control/inst/@tf/tf.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/tf.m 2011-09-19 11:40:51 UTC (rev 8565) +++ trunk/octave-forge/main/control/inst/@tf/tf.m 2011-09-19 14:05:34 UTC (rev 8566) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -29,10 +29,12 @@ ## LTI model to be converted to transfer function. ## @item num ## Numerator or cell of numerators. Each numerator must be a row vector -## containing the exponents of the polynomial in descending order. +## containing the coefficients of the polynomial in descending powers of +## the transfer function variable. ## @item den ## Denominator or cell of denominators. Each denominator must be a row vector -## containing the exponents of the polynomial in descending order. +## containing the coefficients of the polynomial in descending powers of +## the transfer function variable. ## @item tsam ## Sampling time in seconds. If @var{tsam} is not specified, a continuous-time ## model is assumed. @@ -54,20 +56,49 @@ ## octave:2> G = 1/(s+1) ## ## Transfer function "G" from input "u1" to output ... +## ## 1 ## y1: ----- ## s + 1 -## +## +## Continuous-time model. ## octave:3> z = tf ("z", 0.2); ## octave:4> H = 0.095/(z-0.9) ## ## Transfer function "H" from input "u1" to output ... +## ## 0.095 ## y1: ------- ## z - 0.9 ## ## Sampling time: 0.2 s -## octave:5> +## Discrete-time model. +## octave:5> num = @{[1, 5, 7], [1]; [1, 7], [1, 5, 5]@}; +## octave:6> den = @{[1, 5, 6], [1, 2]; [1, 8, 6], [1, 3, 2]@}; +## octave:7> sys = tf (num, den) +## +## Transfer function "sys" from input "u1" to output ... +## +## s^2 + 5 s + 7 +## y1: ------------- +## s^2 + 5 s + 6 +## +## s + 7 +## y2: ------------- +## s^2 + 8 s + 6 +## +## Transfer function "sys" from input "u2" to output ... +## +## 1 +## y1: ----- +## s + 2 +## +## s^2 + 5 s + 5 +## y2: ------------- +## s^2 + 3 s + 2 +## +## Continuous-time model. +## octave:8> ## @end group ## @end example ## @@ -76,7 +107,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.2 +## Version: 0.2.1 function sys = tf (num = {}, den = {}, varargin) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-10-17 12:07:35
|
Revision: 8760 http://octave.svn.sourceforge.net/octave/?rev=8760&view=rev Author: paramaniac Date: 2011-10-17 12:07:25 +0000 (Mon, 17 Oct 2011) Log Message: ----------- control: return number of controllable/observable states, improve doc Modified Paths: -------------- trunk/octave-forge/main/control/inst/isctrb.m trunk/octave-forge/main/control/inst/isobsv.m Modified: trunk/octave-forge/main/control/inst/isctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/isctrb.m 2011-10-17 04:18:56 UTC (rev 8759) +++ trunk/octave-forge/main/control/inst/isctrb.m 2011-10-17 12:07:25 UTC (rev 8760) @@ -16,20 +16,20 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{bool} =} isctrb (@var{sys}) -## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{sys}, @var{tol}) -## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{a}, @var{b}) -## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{a}, @var{b}, @var{e}) -## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{a}, @var{b}, @var{[]}, @var{tol}) -## @deftypefnx {Function File} {@var{bool} =} isctrb (@var{a}, @var{b}, @var{e}, @var{tol}) +## @deftypefn {Function File} {[@var{bool}, @var{ncon}] =} isctrb (@var{sys}) +## @deftypefnx {Function File} {[@var{bool}, @var{ncon}] =} isctrb (@var{sys}, @var{tol}) +## @deftypefnx {Function File} {[@var{bool}, @var{ncon}] =} isctrb (@var{a}, @var{b}) +## @deftypefnx {Function File} {[@var{bool}, @var{ncon}] =} isctrb (@var{a}, @var{b}, @var{e}) +## @deftypefnx {Function File} {[@var{bool}, @var{ncon}] =} isctrb (@var{a}, @var{b}, @var{[]}, @var{tol}) +## @deftypefnx {Function File} {[@var{bool}, @var{ncon}] =} isctrb (@var{a}, @var{b}, @var{e}, @var{tol}) ## Logical check for system controllability. -## Uses SLICOT AB01OD and TG01HD by courtesy of -## @uref{http://www.slicot.org, NICONET e.V.} +## For numerical reasons, @code{isctrb (sys)} +## should be used instead of @code{rank (ctrb (sys))}. ## ## @strong{Inputs} ## @table @var ## @item sys -## LTI model. +## LTI model. Descriptor state-space models are possible. ## @item a ## State transition matrix. ## @item b @@ -46,16 +46,22 @@ ## System is not controllable. ## @item bool = 1 ## System is controllable. +## @item ncon +## Number of controllable states. ## @end table ## +## @strong{Algorithm}@* +## Uses SLICOT AB01OD and TG01HD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} +## ## @seealso{isobsv} ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.3 +## Version: 0.4 -function bool = isctrb (a, b = [], e = [], tol = []) +function [bool, ncont] = isctrb (a, b = [], e = [], tol = []) if (nargin < 1 || nargin > 4) print_usage (); Modified: trunk/octave-forge/main/control/inst/isobsv.m =================================================================== --- trunk/octave-forge/main/control/inst/isobsv.m 2011-10-17 04:18:56 UTC (rev 8759) +++ trunk/octave-forge/main/control/inst/isobsv.m 2011-10-17 12:07:25 UTC (rev 8760) @@ -16,20 +16,20 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{bool} =} isobsv (@var{sys}) -## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{sys}, @var{tol}) -## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{a}, @var{c}) -## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{a}, @var{c}, @var{e}) -## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{a}, @var{c}, @var{[]}, @var{tol}) -## @deftypefnx {Function File} {@var{bool} =} isobsv (@var{a}, @var{c}, @var{e}, @var{tol}) +## @deftypefn {Function File} {[@var{bool}, @var{nobs}] =} isobsv (@var{sys}) +## @deftypefnx {Function File} {[@var{bool}, @var{nobs}] =} isobsv (@var{sys}, @var{tol}) +## @deftypefnx {Function File} {[@var{bool}, @var{nobs}] =} isobsv (@var{a}, @var{c}) +## @deftypefnx {Function File} {[@var{bool}, @var{nobs}] =} isobsv (@var{a}, @var{c}, @var{e}) +## @deftypefnx {Function File} {[@var{bool}, @var{nobs}] =} isobsv (@var{a}, @var{c}, @var{[]}, @var{tol}) +## @deftypefnx {Function File} {[@var{bool}, @var{nobs}] =} isobsv (@var{a}, @var{c}, @var{e}, @var{tol}) ## Logical check for system observability. -## Uses SLICOT AB01OD and TG01HD by courtesy of -## @uref{http://www.slicot.org, NICONET e.V.} +## For numerical reasons, @code{isobsv (sys)} +## should be used instead of @code{rank (obsv (sys))}. ## ## @strong{Inputs} ## @table @var ## @item sys -## LTI model. +## LTI model. Descriptor state-space models are possible. ## @item a ## State transition matrix. ## @item c @@ -46,28 +46,34 @@ ## System is not observable. ## @item bool = 1 ## System is observable. +## @item nobs +## Number of observable states. ## @end table ## +## @strong{Algorithm}@* +## Uses SLICOT AB01OD and TG01HD by courtesy of +## @uref{http://www.slicot.org, NICONET e.V.} +## ## @seealso{isctrb} ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.3 +## Version: 0.4 -function bool = isobsv (a, c = [], e = [], tol = []) +function [bool, nobs] = isobsv (a, c = [], e = [], tol = []) if (nargin == 0) print_usage (); - elseif (isa (a, "lti")) # isobsv (sys), isobsv (sys, tol) + elseif (isa (a, "lti")) # isobsv (sys), isobsv (sys, tol) if (nargin > 2) print_usage (); endif - bool = isctrb (a.', c); # transpose is overloaded + [bool, nobs] = isctrb (a.', c); # transpose is overloaded elseif (nargin < 2 || nargin > 4) print_usage (); - else # isobsv (a, c), isobsv (a, c, e), ... - bool = isctrb (a.', c.', e.', tol); + else # isobsv (a, c), isobsv (a, c, e), ... + [bool, nobs] = isctrb (a.', c.', e.', tol); endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-10-22 04:40:21
|
Revision: 8845 http://octave.svn.sourceforge.net/octave/?rev=8845&view=rev Author: paramaniac Date: 2011-10-22 04:40:15 +0000 (Sat, 22 Oct 2011) Log Message: ----------- control: minor doc fixes Modified Paths: -------------- trunk/octave-forge/main/control/inst/mixsyn.m trunk/octave-forge/main/control/inst/ncfsyn.m Modified: trunk/octave-forge/main/control/inst/mixsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/mixsyn.m 2011-10-22 04:14:11 UTC (rev 8844) +++ trunk/octave-forge/main/control/inst/mixsyn.m 2011-10-22 04:40:15 UTC (rev 8845) @@ -17,7 +17,7 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}] =} mixsyn (@var{G}, @var{W1}, @var{W2}, @var{W3}, @dots{}) -## Solve stacked S/KS/T H-inf problem. Bound the largest singular values +## Solve stacked S/KS/T H-infinity problem. Bound the largest singular values ## of @var{S} (for performance), @var{K S} (to penalize large inputs) and ## @var{T} (for robustness and to avoid sensitivity to noise). ## In other words, the inputs r are excited by a harmonic test signal. Modified: trunk/octave-forge/main/control/inst/ncfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/ncfsyn.m 2011-10-22 04:14:11 UTC (rev 8844) +++ trunk/octave-forge/main/control/inst/ncfsyn.m 2011-10-22 04:40:15 UTC (rev 8845) @@ -17,8 +17,8 @@ ## -*- texinfo -*- ## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}, @var{info}] =} ncfsyn (@var{G}, @var{W1}, @var{W2}, @var{factor}) -## Normalized Coprime Factor (NCF) H-infinity synthesis. -## Compute positive feedback controller using the McFarlane/Glover Loop Shaping Design Procedure. +## Loop shaping H-infinity synthesis. Compute positive feedback controller using +## the McFarlane/Glover normalized coprime factor (NCF) loop shaping design procedure. ## ## @strong{Inputs} ## @table @var @@ -46,7 +46,7 @@ ## @item N ## State-space model of the closed loop depicted below. ## @item gamma -## L-infinity norm of @var{N}. +## L-infinity norm of @var{N}. @code{gamma = norm (N, inf)}. ## @item info ## Structure containing additional information. ## @item info.emax This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-25 07:20:54
|
Revision: 9178 http://octave.svn.sourceforge.net/octave/?rev=9178&view=rev Author: paramaniac Date: 2011-11-25 07:20:47 +0000 (Fri, 25 Nov 2011) Log Message: ----------- control: replace @ifinfo by @ifnottex to make text appear in help and html Modified Paths: -------------- trunk/octave-forge/main/control/inst/Boeing707.m trunk/octave-forge/main/control/inst/__frequency_vector__.m trunk/octave-forge/main/control/inst/ctrb.m trunk/octave-forge/main/control/inst/obsv.m Modified: trunk/octave-forge/main/control/inst/Boeing707.m =================================================================== --- trunk/octave-forge/main/control/inst/Boeing707.m 2011-11-24 22:01:00 UTC (rev 9177) +++ trunk/octave-forge/main/control/inst/Boeing707.m 2011-11-25 07:20:47 UTC (rev 9178) @@ -24,9 +24,9 @@ ## ($M = 0.26$, $G_{a0} = -3^{\circ}$, ${\alpha}_0 = 4^{\circ}$, ${\kappa}= 50^{\circ}$). ## @end tex ## @end iftex -## @ifinfo +## @ifnottex ## (@var{M} = 0.26, @var{Ga0} = -3 deg, @var{alpha0} = 4 deg, @var{kappa} = 50 deg). -## @end ifinfo +## @end ifnottex ## ## System inputs: (1) thrust and (2) elevator angle. ## Modified: trunk/octave-forge/main/control/inst/__frequency_vector__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_vector__.m 2011-11-24 22:01:00 UTC (rev 9177) +++ trunk/octave-forge/main/control/inst/__frequency_vector__.m 2011-11-25 07:20:47 UTC (rev 9178) @@ -26,9 +26,9 @@ ## $ [ 10^{w_{min}}, 10^{w_{max}} ] $ ## @end tex ## @end iftex -## @ifinfo +## @ifnottex ## [10^@var{wmin}, 10^@var{wmax}] -## @end ifinfo +## @end ifnottex ## ## Used by @command{__frequency_response__} ## @end deftypefn Modified: trunk/octave-forge/main/control/inst/ctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/ctrb.m 2011-11-24 22:01:00 UTC (rev 9177) +++ trunk/octave-forge/main/control/inst/ctrb.m 2011-11-25 07:20:47 UTC (rev 9178) @@ -43,12 +43,12 @@ ## $$ C_o = [ B \\ \\ AB \\ \\ A^2B \\ \\ldots \\ A^{n-1}B ] $$ ## @end tex ## @end iftex -## @ifinfo +## @ifnottex ## @example ## 2 n-1 ## Co = [ B AB A B ... A B ] ## @end example -## @end ifinfo +## @end ifnottex ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> Modified: trunk/octave-forge/main/control/inst/obsv.m =================================================================== --- trunk/octave-forge/main/control/inst/obsv.m 2011-11-24 22:01:00 UTC (rev 9177) +++ trunk/octave-forge/main/control/inst/obsv.m 2011-11-25 07:20:47 UTC (rev 9178) @@ -47,7 +47,7 @@ ## CA^{n-1} } \\right ] $$ ## @end tex ## @end iftex -## @ifinfo +## @ifnottex ## @example ## @group ## | C | @@ -57,7 +57,7 @@ ## | CA^(n-1) | ## @end group ## @end example -## @end ifinfo +## @end ifnottex ## @end deftypefn ## Author: Lukas Reichlin <luk...@gm...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-11-26 15:59:03
|
Revision: 9198 http://octave.svn.sourceforge.net/octave/?rev=9198&view=rev Author: paramaniac Date: 2011-11-26 15:58:55 +0000 (Sat, 26 Nov 2011) Log Message: ----------- control: move tests from ltimodels to the files of individual LTI methods Modified Paths: -------------- trunk/octave-forge/main/control/inst/@lti/c2d.m trunk/octave-forge/main/control/inst/@lti/d2c.m trunk/octave-forge/main/control/inst/@lti/feedback.m trunk/octave-forge/main/control/inst/@lti/horzcat.m trunk/octave-forge/main/control/inst/@lti/inv.m trunk/octave-forge/main/control/inst/@lti/minreal.m trunk/octave-forge/main/control/inst/@lti/mtimes.m trunk/octave-forge/main/control/inst/@lti/norm.m trunk/octave-forge/main/control/inst/@lti/plus.m trunk/octave-forge/main/control/inst/@lti/prescale.m trunk/octave-forge/main/control/inst/@lti/sminreal.m trunk/octave-forge/main/control/inst/@lti/zero.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/c2d.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/c2d.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/c2d.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -49,7 +49,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.2 +## Version: 0.3 function sys = c2d (sys, tsam, method = "std", w0 = 0) @@ -81,3 +81,142 @@ sys.tsam = tsam; endfunction + + +## bilinear transformation +## using oct-file directly +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ].'; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ].'; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ].'; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ].'; +%! +%! [Ao, Bo, Co, Do] = slab04md (A, B, C, D, 1.0, 1.0, false); +%! +%! Ae = [ -1.0000 -4.0000 +%! -4.0000 -1.0000 ]; +%! +%! Be = [ 2.8284 0.0000 +%! 0.0000 -2.8284 ]; +%! +%! Ce = [ 0.0000 2.8284 +%! -2.8284 0.0000 ]; +%! +%! De = [ -1.0000 0.0000 +%! 0.0000 -3.0000 ]; +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (Mo, Me, 1e-4); + + +## bilinear transformation +## user function +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ].'; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ].'; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ].'; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ].'; +%! +%! [Ao, Bo, Co, Do] = ssdata (c2d (ss (A, B, C, D), 2, "tustin")); +%! +%! Ae = [ -1.0000 -4.0000 +%! -4.0000 -1.0000 ]; +%! +%! Be = [ 2.8284 0.0000 +%! 0.0000 -2.8284 ]; +%! +%! Ce = [ 0.0000 2.8284 +%! -2.8284 0.0000 ]; +%! +%! De = [ -1.0000 0.0000 +%! 0.0000 -3.0000 ]; +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (Mo, Me, 1e-4); + + +## bilinear transformation +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "tustin"), "tustin")); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); + + +## zero-order hold +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "zoh"), "zoh")); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); + + +## bilinear transformation with pre-warping +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "prewarp", 1000), "prewarp", 1000)); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/d2c.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/d2c.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -47,7 +47,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2011 -## Version: 0.1 +## Version: 0.2 function sys = d2c (sys, method = "std", w0 = 0) @@ -75,3 +75,72 @@ sys.tsam = 0; endfunction + + +## bilinear transformation +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "tustin"), "tustin")); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); + + +## zero-order hold +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "zoh"), "zoh")); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); + + +## bilinear transformation with pre-warping +## both directions +%!shared Mo, Me +%! A = [ 1.0 0.5 +%! 0.5 1.0 ]; +%! +%! B = [ 0.0 -1.0 +%! 1.0 0.0 ]; +%! +%! C = [ -1.0 0.0 +%! 0.0 1.0 ]; +%! +%! D = [ 1.0 0.0 +%! 0.0 -1.0 ]; +%! +%! [Ao, Bo, Co, Do] = ssdata (d2c (c2d (ss (A, B, C, D), 2, "prewarp", 1000), "prewarp", 1000)); +%! +%! Mo = [Ao, Bo; Co, Do]; +%! Me = [A, B; C, D]; +%! +%!assert (Mo, Me, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/feedback.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/feedback.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/feedback.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -67,7 +67,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.4 +## Version: 0.5 function sys = feedback (sys1, sys2, feedin, feedout, fbsign = -1) @@ -182,3 +182,82 @@ endif endfunction + + +## Feedback inter-connection of two systems in state-space form +## Test from SLICOT AB05ND +%!shared M, Me +%! A1 = [ 1.0 0.0 -1.0 +%! 0.0 -1.0 1.0 +%! 1.0 1.0 2.0 ]; +%! +%! B1 = [ 1.0 1.0 0.0 +%! 2.0 0.0 1.0 ].'; +%! +%! C1 = [ 3.0 -2.0 1.0 +%! 0.0 1.0 0.0 ]; +%! +%! D1 = [ 1.0 0.0 +%! 0.0 1.0 ]; +%! +%! A2 = [-3.0 0.0 0.0 +%! 1.0 0.0 1.0 +%! 0.0 -1.0 2.0 ]; +%! +%! B2 = [ 0.0 -1.0 0.0 +%! 1.0 0.0 2.0 ].'; +%! +%! C2 = [ 1.0 1.0 0.0 +%! 1.0 1.0 -1.0 ]; +%! +%! D2 = [ 1.0 1.0 +%! 0.0 1.0 ]; +%! +%! sys1 = ss (A1, B1, C1, D1); +%! sys2 = ss (A2, B2, C2, D2); +%! sys = feedback (sys1, sys2); +%! [A, B, C, D] = ssdata (sys); +%! M = [A, B; C, D]; +%! +%! Ae = [-0.5000 -0.2500 -1.5000 -1.2500 -1.2500 0.7500 +%! -1.5000 -0.2500 0.5000 -0.2500 -0.2500 -0.2500 +%! 1.0000 0.5000 2.0000 -0.5000 -0.5000 0.5000 +%! 0.0000 0.5000 0.0000 -3.5000 -0.5000 0.5000 +%! -1.5000 1.2500 -0.5000 1.2500 0.2500 1.2500 +%! 0.0000 1.0000 0.0000 -1.0000 -2.0000 3.0000 ]; +%! +%! Be = [ 0.5000 0.7500 +%! 0.5000 -0.2500 +%! 0.0000 0.5000 +%! 0.0000 0.5000 +%! -0.5000 0.2500 +%! 0.0000 1.0000 ]; +%! +%! Ce = [ 1.5000 -1.2500 0.5000 -0.2500 -0.2500 -0.2500 +%! 0.0000 0.5000 0.0000 -0.5000 -0.5000 0.5000 ]; +%! +%! De = [ 0.5000 -0.2500 +%! 0.0000 0.5000 ]; +%! +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (M, Me, 1e-4); + + +## sensitivity function +## Note the correct physical meaning of the states. +## Test would fail on a commercial octave clone +## because of wrong signs of matrices B and C. +## NOTE: Don't use T = I - S for complementary sensitivity, +## use T = feedback (L) instead! +%!shared S1, S2 +%! P = ss (-2, 3, 4, 5); # meaningless numbers +%! C = ss (-1, 1, 1, 0); # ditto +%! L = P * C; +%! I = eye (size (L)); +%! S1 = feedback (I, L*-I, "+"); # draw a block diagram for better understanding +%! S2 = inv (I + L); +%!assert (S1.a, S2.a, 1e-4); +%!assert (S1.b, S2.b, 1e-4); +%!assert (S1.c, S2.c, 1e-4); +%!assert (S1.d, S2.d, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/horzcat.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/horzcat.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/horzcat.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -21,7 +21,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.1 +## Version: 0.2 function sys = horzcat (sys, varargin) @@ -47,3 +47,63 @@ endfor endfunction + + +## Rowwise concatenation of two systems in state-space form +## Test from SLICOT AB05OD +%!shared M, Me +%! A1 = [ 1.0 0.0 -1.0 +%! 0.0 -1.0 1.0 +%! 1.0 1.0 2.0 ]; +%! +%! B1 = [ 1.0 1.0 0.0 +%! 2.0 0.0 1.0 ].'; +%! +%! C1 = [ 3.0 -2.0 1.0 +%! 0.0 1.0 0.0 ]; +%! +%! D1 = [ 1.0 0.0 +%! 0.0 1.0 ]; +%! +%! A2 = [-3.0 0.0 0.0 +%! 1.0 0.0 1.0 +%! 0.0 -1.0 2.0 ]; +%! +%! B2 = [ 0.0 -1.0 0.0 +%! 1.0 0.0 2.0 ].'; +%! +%! C2 = [ 1.0 1.0 0.0 +%! 1.0 1.0 -1.0 ]; +%! +%! D2 = [ 1.0 1.0 +%! 0.0 1.0 ]; +%! +%! sys1 = ss (A1, B1, C1, D1); +%! sys2 = ss (A2, B2, C2, D2); +%! sys = [sys1, sys2]; +%! [A, B, C, D] = ssdata (sys); +%! M = [A, B; C, D]; +%! +%! Ae = [ 1.0000 0.0000 -1.0000 0.0000 0.0000 0.0000 +%! 0.0000 -1.0000 1.0000 0.0000 0.0000 0.0000 +%! 1.0000 1.0000 2.0000 0.0000 0.0000 0.0000 +%! 0.0000 0.0000 0.0000 -3.0000 0.0000 0.0000 +%! 0.0000 0.0000 0.0000 1.0000 0.0000 1.0000 +%! 0.0000 0.0000 0.0000 0.0000 -1.0000 2.0000 ]; +%! +%! Be = [ 1.0000 2.0000 0.0000 0.0000 +%! 1.0000 0.0000 0.0000 0.0000 +%! 0.0000 1.0000 0.0000 0.0000 +%! 0.0000 0.0000 0.0000 1.0000 +%! 0.0000 0.0000 -1.0000 0.0000 +%! 0.0000 0.0000 0.0000 2.0000 ]; +%! +%! Ce = [ 3.0000 -2.0000 1.0000 1.0000 1.0000 0.0000 +%! 0.0000 1.0000 0.0000 1.0000 1.0000 -1.0000 ]; +%! +%! De = [ 1.0000 0.0000 1.0000 1.0000 +%! 0.0000 1.0000 0.0000 1.0000 ]; +%! +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (M, Me, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/inv.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/inv.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/inv.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 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 retsys = inv (sys) @@ -38,4 +38,47 @@ ## TODO: handle i/o names -endfunction \ No newline at end of file +endfunction + + +## inverse of state-space models +## test from SLICOT AB07ND +## result differs intentionally from a commercial +## implementation of an octave-like language +%!shared M, Me +%! A = [ 1.0 2.0 0.0 +%! 4.0 -1.0 0.0 +%! 0.0 0.0 1.0 ]; +%! +%! B = [ 1.0 0.0 +%! 0.0 1.0 +%! 1.0 0.0 ]; +%! +%! C = [ 0.0 1.0 -1.0 +%! 0.0 0.0 1.0 ]; +%! +%! D = [ 4.0 0.0 +%! 0.0 1.0 ]; +%! +%! sys = ss (A, B, C, D); +%! sysinv = inv (sys); +%! [Ai, Bi, Ci, Di] = ssdata (sysinv); +%! M = [Ai, Bi; Ci, Di]; +%! +%! Ae = [ 1.0000 1.7500 0.2500 +%! 4.0000 -1.0000 -1.0000 +%! 0.0000 -0.2500 1.2500 ]; +%! +%! Be = [-0.2500 0.0000 +%! 0.0000 -1.0000 +%! -0.2500 0.0000 ]; +%! +%! Ce = [ 0.0000 0.2500 -0.2500 +%! 0.0000 0.0000 1.0000 ]; +%! +%! De = [ 0.2500 0.0000 +%! 0.0000 1.0000 ]; +%! +%! Me = [Ae, Be; Ce, De]; # Me = [Ae, -Be; -Ce, De]; +%! +%!assert (M, Me, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/minreal.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/minreal.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/minreal.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -23,7 +23,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.2 +## Version: 0.3 function sys = minreal (sys, tol = "def") @@ -37,4 +37,149 @@ sys = __minreal__ (sys, tol); -endfunction \ No newline at end of file +endfunction + + +## ss: minreal (SLICOT TB01PD) +%!shared C, D +%! +%! A = ss (-2, 3, 4, 5); +%! B = A / A; +%! C = minreal (B, 1e-15); +%! D = ss (1); +%! +%!assert (C.a, D.a); +%!assert (C.b, D.b); +%!assert (C.c, D.c); +%!assert (C.d, D.d); + +%!shared M, Me +%! A = [ 1.0 2.0 0.0 +%! 4.0 -1.0 0.0 +%! 0.0 0.0 1.0 ]; +%! +%! B = [ 1.0 +%! 0.0 +%! 1.0 ]; +%! +%! C = [ 0.0 1.0 -1.0 +%! 0.0 0.0 1.0 ]; +%! +%! D = zeros (2, 1); +%! +%! sys = ss (A, B, C, D, "scaled", true); +%! sysmin = minreal (sys, 0.0); +%! [Ar, Br, Cr, Dr] = ssdata (sysmin); +%! M = [Ar, Br; Cr, Dr]; +%! +%! Ae = [ 1.0000 -1.4142 1.4142 +%! -2.8284 0.0000 1.0000 +%! 2.8284 1.0000 0.0000 ]; +%! +%! Be = [-1.0000 +%! 0.7071 +%! 0.7071 ]; +%! +%! Ce = [ 0.0000 0.0000 -1.4142 +%! 0.0000 0.7071 0.7071 ]; +%! +%! De = zeros (2, 1); +%! +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (M, Me, 1e-4); + + +## dss: minreal (SLICOT TG01JD) +## FIXME: Test fails with larger ldwork in sltg01jd.cc +#%!shared Ar, Br, Cr, Dr, Er, Ae, Be, Ce, De, Ee +#%! A = [ -2 -3 0 0 0 0 0 0 0 +#%! 1 0 0 0 0 0 0 0 0 +#%! 0 0 -2 -3 0 0 0 0 0 +#%! 0 0 1 0 0 0 0 0 0 +#%! 0 0 0 0 1 0 0 0 0 +#%! 0 0 0 0 0 1 0 0 0 +#%! 0 0 0 0 0 0 1 0 0 +#%! 0 0 0 0 0 0 0 1 0 +#%! 0 0 0 0 0 0 0 0 1 ]; +#%! +#%! E = [ 1 0 0 0 0 0 0 0 0 +#%! 0 1 0 0 0 0 0 0 0 +#%! 0 0 1 0 0 0 0 0 0 +#%! 0 0 0 1 0 0 0 0 0 +#%! 0 0 0 0 0 0 0 0 0 +#%! 0 0 0 0 1 0 0 0 0 +#%! 0 0 0 0 0 0 0 0 0 +#%! 0 0 0 0 0 0 1 0 0 +#%! 0 0 0 0 0 0 0 1 0 ]; +#%! +#%! B = [ 1 0 +#%! 0 0 +#%! 0 1 +#%! 0 0 +#%! -1 0 +#%! 0 0 +#%! 0 -1 +#%! 0 0 +#%! 0 0 ]; +#%! +#%! C = [ 1 0 1 -3 0 1 0 2 0 +#%! 0 1 1 3 0 1 0 0 1 ]; +#%! +#%! D = zeros (2, 2); +#%! +#%! sys = dss (A, B, C, D, E, "scaled", true); +#%! sysmin = minreal (sys, 0.0); +#%! [Ar, Br, Cr, Dr, Er] = dssdata (sysmin); +#%! +#%! Ae = [ 1.0000 -0.0393 -0.0980 -0.1066 0.0781 -0.2330 0.0777 +#%! 0.0000 1.0312 0.2717 0.2609 -0.1533 0.6758 -0.3553 +#%! 0.0000 0.0000 1.3887 0.6699 -0.4281 1.6389 -0.7615 +#%! 0.0000 0.0000 0.0000 -1.2147 0.2423 -0.9792 0.4788 +#%! 0.0000 0.0000 0.0000 0.0000 -1.0545 0.5035 -0.2788 +#%! 0.0000 0.0000 0.0000 0.0000 0.0000 1.6355 -0.4323 +#%! 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 ]; +#%! +#%! Ee = [ 0.4100 0.2590 0.5080 -0.3109 0.0705 0.1429 -0.1477 +#%! -0.7629 -0.3464 0.0992 -0.3007 0.0619 0.2483 -0.0152 +#%! 0.1120 -0.2124 -0.4184 -0.1288 0.0569 -0.4213 -0.6182 +#%! 0.0000 0.1122 -0.0039 0.2771 -0.0758 0.0975 0.3923 +#%! 0.0000 0.0000 0.3708 -0.4290 0.1006 0.1402 -0.2699 +#%! 0.0000 0.0000 0.0000 0.0000 0.9458 -0.2211 0.2378 +#%! 0.0000 0.0000 0.0000 0.5711 0.2648 0.5948 -0.5000 ]; +#%! +#%! Be = [ -0.5597 0.2363 +#%! -0.4843 -0.0498 +#%! -0.4727 -0.1491 +#%! 0.1802 1.1574 +#%! 0.5995 0.1556 +#%! -0.1729 -0.3999 +#%! 0.0000 0.2500 ]; +#%! +#%! Ce = [ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 4.0000 +#%! 0.0000 0.0000 0.0000 0.0000 0.0000 3.1524 -1.7500 ]; +#%! +#%! De = zeros (2, 2); +#%! +#%!assert (Ar, Ae, 1e-4); +#%!assert (Br, Be, 1e-4); +#%!assert (Cr, Ce, 1e-4); +#%!assert (Dr, De, 1e-4); +#%!assert (Er, Ee, 1e-4); + + +## tf: minreal +%!shared a, b, c, d +%! s = tf ("s"); +%! G1 = (s+1)*s*5/(s+1)/(s^2+s+1); +%! G2 = tf ([1, 1, 1], [2, 2, 2]); +%! G1min = minreal (G1); +%! G2min = minreal (G2); +%! a = G1min.num{1, 1}; +%! b = G1min.den{1, 1}; +%! c = G2min.num{1, 1}; +%! d = G2min.den{1, 1}; +%!assert (a, [5, 0], 1e-4); +%!assert (b, [1, 1, 1], 1e-4); +%!assert (c, 0.5, 1e-4); +%!assert (d, 1, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/mtimes.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/mtimes.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/mtimes.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -21,7 +21,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.1 +## Version: 0.2 function sys = mtimes (sys2, sys1) @@ -72,3 +72,83 @@ sys = __sys_group__ (sys1, sys2); #} ## Don't forget to adapt @tf/__sys_connect__.m draft code + + +## mtimes +%!shared sysmat, sysmat_exp +%! sys1 = ss ([0, 1; -3, -2], [0; 1], [-5, 1], [2]); +%! sys2 = ss ([-10], [1], [-40], [5]); +%! sys3 = sys2 * sys1; +%! [A, B, C, D] = ssdata (sys3); +%! sysmat = [A, B; C, D]; +%! A_exp = [ -10 -5 1 +%! 0 0 1 +%! 0 -3 -2 ]; +%! B_exp = [ 2 +%! 0 +%! 1 ]; +%! C_exp = [ -40 -25 5 ]; +%! D_exp = [ 10 ]; +%! sysmat_exp = [A_exp, B_exp; C_exp, D_exp]; +%!assert (sysmat, sysmat_exp) + + +## Cascade inter-connection of two systems in state-space form +## Test from SLICOT AB05MD +## TODO: order of united state vector: consistency vs. compatibility? +#%!shared M, Me +#%! A1 = [ 1.0 0.0 -1.0 +#%! 0.0 -1.0 1.0 +#%! 1.0 1.0 2.0 ]; +#%! +#%! B1 = [ 1.0 1.0 0.0 +#%! 2.0 0.0 1.0 ].'; +#%! +#%! C1 = [ 3.0 -2.0 1.0 +#%! 0.0 1.0 0.0 ]; +#%! +#%! D1 = [ 1.0 0.0 +#%! 0.0 1.0 ]; +#%! +#%! A2 = [-3.0 0.0 0.0 +#%! 1.0 0.0 1.0 +#%! 0.0 -1.0 2.0 ]; +#%! +#%! B2 = [ 0.0 -1.0 0.0 +#%! 1.0 0.0 2.0 ].'; +#%! +#%! C2 = [ 1.0 1.0 0.0 +#%! 1.0 1.0 -1.0 ]; +#%! +#%! D2 = [ 1.0 1.0 +#%! 0.0 1.0 ]; +#%! +#%! sys1 = ss (A1, B1, C1, D1); +#%! sys2 = ss (A2, B2, C2, D2); +#%! sys = sys2 * sys1; +#%! [A, B, C, D] = ssdata (sys); +#%! M = [A, B; C, D]; +#%! +#%! Ae = [ 1.0000 0.0000 -1.0000 0.0000 0.0000 0.0000 +#%! 0.0000 -1.0000 1.0000 0.0000 0.0000 0.0000 +#%! 1.0000 1.0000 2.0000 0.0000 0.0000 0.0000 +#%! 0.0000 1.0000 0.0000 -3.0000 0.0000 0.0000 +#%! -3.0000 2.0000 -1.0000 1.0000 0.0000 1.0000 +#%! 0.0000 2.0000 0.0000 0.0000 -1.0000 2.0000 ]; +#%! +#%! Be = [ 1.0000 2.0000 +#%! 1.0000 0.0000 +#%! 0.0000 1.0000 +#%! 0.0000 1.0000 +#%! -1.0000 0.0000 +#%! 0.0000 2.0000 ]; +#%! +#%! Ce = [ 3.0000 -1.0000 1.0000 1.0000 1.0000 0.0000 +#%! 0.0000 1.0000 0.0000 1.0000 1.0000 -1.0000 ]; +#%! +#%! De = [ 1.0000 1.0000 +#%! 0.0000 1.0000 ]; +#%! +#%! Me = [Ae, Be; Ce, De]; +#%! +#%!assert (M, Me, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/norm.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/norm.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/norm.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -28,7 +28,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.4.1 +## Version: 0.5 function [gain, varargout] = norm (sys, ntype = "2", tol = 0.01) @@ -116,3 +116,29 @@ endif endfunction + + +## norm ct +%!shared H2, Hinf +%! sys = ss (-1, 1, 1, 0); +%! H2 = norm (sys, 2); +%! Hinf = norm (sys, inf); +%!assert (H2, 0.7071, 1.5e-5); +%!assert (Hinf, 1, 5e-4); + + +## norm dt +%!shared H2, Hinf +%! a = [ 2.417 -1.002 0.5488 +%! 2 0 0 +%! 0 0.5 0 ]; +%! b = [ 1 +%! 0 +%! 0 ]; +%! c = [-0.424 0.436 -0.4552 ]; +%! d = [ 1 ]; +%! sys = ss (a, b, c, d, 0.1); +%! H2 = norm (sys, 2); +%! Hinf = norm (sys, inf); +%!assert (H2, 1.2527, 1.5e-5); +%!assert (Hinf, 2.7, 0.1); Modified: trunk/octave-forge/main/control/inst/@lti/plus.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/plus.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/plus.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,4 +1,4 @@ -## Copyright (C) 2009 Lukas F. Reichlin +## Copyright (C) 2009, 2011 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 sys = plus (sys1, sys2) @@ -46,3 +46,63 @@ sys = out_scl * sys * in_scl; endfunction + + +## Parallel inter-connection of two systems in state-space form +## Test from SLICOT AB05PD +%!shared M, Me +%! A1 = [ 1.0 0.0 -1.0 +%! 0.0 -1.0 1.0 +%! 1.0 1.0 2.0 ]; +%! +%! B1 = [ 1.0 1.0 0.0 +%! 2.0 0.0 1.0 ].'; +%! +%! C1 = [ 3.0 -2.0 1.0 +%! 0.0 1.0 0.0 ]; +%! +%! D1 = [ 1.0 0.0 +%! 0.0 1.0 ]; +%! +%! A2 = [-3.0 0.0 0.0 +%! 1.0 0.0 1.0 +%! 0.0 -1.0 2.0 ]; +%! +%! B2 = [ 0.0 -1.0 0.0 +%! 1.0 0.0 2.0 ].'; +%! +%! C2 = [ 1.0 1.0 0.0 +%! 1.0 1.0 -1.0 ]; +%! +%! D2 = [ 1.0 1.0 +%! 0.0 1.0 ]; +%! +%! sys1 = ss (A1, B1, C1, D1); +%! sys2 = ss (A2, B2, C2, D2); +%! sys = sys1 + sys2; +%! [A, B, C, D] = ssdata (sys); +%! M = [A, B; C, D]; +%! +%! Ae = [ 1.0000 0.0000 -1.0000 0.0000 0.0000 0.0000 +%! 0.0000 -1.0000 1.0000 0.0000 0.0000 0.0000 +%! 1.0000 1.0000 2.0000 0.0000 0.0000 0.0000 +%! 0.0000 0.0000 0.0000 -3.0000 0.0000 0.0000 +%! 0.0000 0.0000 0.0000 1.0000 0.0000 1.0000 +%! 0.0000 0.0000 0.0000 0.0000 -1.0000 2.0000 ]; +%! +%! Be = [ 1.0000 2.0000 +%! 1.0000 0.0000 +%! 0.0000 1.0000 +%! 0.0000 1.0000 +%! -1.0000 0.0000 +%! 0.0000 2.0000 ]; +%! +%! Ce = [ 3.0000 -2.0000 1.0000 1.0000 1.0000 0.0000 +%! 0.0000 1.0000 0.0000 1.0000 1.0000 -1.0000 ]; +%! +%! De = [ 2.0000 1.0000 +%! 0.0000 2.0000 ]; +%! +%! Me = [Ae, Be; Ce, De]; +%! +%!assert (M, Me, 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/prescale.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/prescale.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/prescale.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -59,7 +59,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: June 2011 -## Version: 0.1 +## Version: 0.2 function [retsys, varargout] = prescale (sys) @@ -79,3 +79,219 @@ endif endfunction + + +## Scaling of state-space models, direct access to TB01ID +%!shared Ao, Bo, Co, SCALEo, MAXREDo, Ae, Be, Ce, SCALEe, MAXREDe +%! A = [ 0.0 1.0000e+000 0.0 0.0 0.0 +%! -1.5800e+006 -1.2570e+003 0.0 0.0 0.0 +%! 3.5410e+014 0.0 -1.4340e+003 0.0 -5.3300e+011 +%! 0.0 0.0 0.0 0.0 1.0000e+000 +%! 0.0 0.0 0.0 -1.8630e+004 -1.4820e+000 ]; +%! +%! B = [ 0.0 0.0 +%! 1.1030e+002 0.0 +%! 0.0 0.0 +%! 0.0 0.0 +%! 0.0 8.3330e-003 ]; +%! +%! C = [ 1.0000e+000 0.0 0.0 0.0 0.0 +%! 0.0 0.0 1.0000e+000 0.0 0.0 +%! 0.0 0.0 0.0 1.0000e+000 0.0 +%! 6.6640e-001 0.0 -6.2000e-013 0.0 0.0 +%! 0.0 0.0 -1.0000e-003 1.8960e+006 1.5080e+002 ]; +%! +%! MAXRED = 0.0; +%! +%! [Ao, Bo, Co, MAXREDo, SCALEo] = sltb01id (A, B, C, MAXRED); +%! +%! Ae = [ 0.0000000D+00 0.1000000D+05 0.0000000D+00 0.0000000D+00 0.0000000D+00 +%! -0.1580000D+03 -0.1257000D+04 0.0000000D+00 0.0000000D+00 0.0000000D+00 +%! 0.3541000D+05 0.0000000D+00 -0.1434000D+04 0.0000000D+00 -0.5330000D+03 +%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.1000000D+03 +%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 -0.1863000D+03 -0.1482000D+01 ]; +%! +%! Be = [ 0.0000000D+00 0.0000000D+00 +%! 0.1103000D+04 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.8333000D+02 ]; +%! +%! Ce = [ 0.1000000D-04 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 0.1000000D+06 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.1000000D-05 0.0000000D+00 +%! 0.6664000D-05 0.0000000D+00 -0.6200000D-07 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 -0.1000000D+03 0.1896000D+01 0.1508000D-01 ]; +%! +%! SCALEe = [0.1000000D-04 0.1000000D+00 0.1000000D+06 0.1000000D-05 0.1000000D-03 ]; +%! +%! MAXREDe = 0.3488E+10; +%! +%!assert (Ao, Ae, 1e-4); +%!assert (Bo, Be, 1e-4); +%!assert (Co, Ce, 1e-4); +%!assert (MAXREDo, MAXREDe, 1e6); +%!assert (SCALEo, SCALEe.', 1e-4); + + +## Scaling of descriptor state-space models, direct access to TG01AD +%!shared Ao, Eo, Bo, Co, LSCALEo, RSCALEo, Ae, Ee, Be, Ce, LSCALEe, RSCALEe +%! A = [ -1 0 0 0.003 +%! 0 0 0.1000 0.02 +%! 100 10 0 0.4 +%! 0 0 0 0.0]; +%! +%! E = [ 1 0.2 0 0.0 +%! 0 1 0 0.01 +%! 300 90 6 0.3 +%! 0 0 20 0.0]; +%! +%! B = [ 10 0 +%! 0 0 +%! 0 1000 +%! 10000 10000]; +%! +%! C = [ -0.1 0.0 0.001 0.0 +%! 0.0 0.01 -0.001 0.0001]; +%! +%! TRESH = 0.0; +%! +%! [Ao, Eo, Bo, Co, LSCALEo, RSCALEo] = sltg01ad (A, E, B, C, TRESH); +%! +%! Ae = [ -1.0000 0.0000 0.0000 0.3000 +%! 0.0000 0.0000 1.0000 2.0000 +%! 1.0000 0.1000 0.0000 0.4000 +%! 0.0000 0.0000 0.0000 0.0000]; +%! +%! Ee = [ 1.0000 0.2000 0.0000 0.0000 +%! 0.0000 1.0000 0.0000 1.0000 +%! 3.0000 0.9000 0.6000 0.3000 +%! 0.0000 0.0000 0.2000 0.0000 ]; +%! +%! Be = [100.0000 0.0000 +%! 0.0000 0.0000 +%! 0.0000 100.0000 +%! 100.0000 100.0000 ]; +%! +%! Ce = [ -0.0100 0.0000 0.0010 0.0000 +%! 0.0000 0.0010 -0.0010 0.0010]; +%! +%! LSCALEe = [ 10.0000 10.0000 0.1000 0.0100 ]; +%! +%! RSCALEe = [ 0.1000 0.1000 1.0000 10.0000 ]; +%! +%!assert (Ao, Ae, 1e-4); +%!assert (Eo, Ee, 1e-4); +%!assert (Bo, Be, 1e-4); +%!assert (Co, Ce, 1e-4); +%!assert (LSCALEo, LSCALEe.', 1e-4); +%!assert (RSCALEo, RSCALEe.', 1e-4); + + +## Scaling of state-space models, user function +%!shared Ao, Bo, Co, INFOo, Ae, Be, Ce, SCALEe +%! A = [ 0.0 1.0000e+000 0.0 0.0 0.0 +%! -1.5800e+006 -1.2570e+003 0.0 0.0 0.0 +%! 3.5410e+014 0.0 -1.4340e+003 0.0 -5.3300e+011 +%! 0.0 0.0 0.0 0.0 1.0000e+000 +%! 0.0 0.0 0.0 -1.8630e+004 -1.4820e+000 ]; +%! +%! B = [ 0.0 0.0 +%! 1.1030e+002 0.0 +%! 0.0 0.0 +%! 0.0 0.0 +%! 0.0 8.3330e-003 ]; +%! +%! C = [ 1.0000e+000 0.0 0.0 0.0 0.0 +%! 0.0 0.0 1.0000e+000 0.0 0.0 +%! 0.0 0.0 0.0 1.0000e+000 0.0 +%! 6.6640e-001 0.0 -6.2000e-013 0.0 0.0 +%! 0.0 0.0 -1.0000e-003 1.8960e+006 1.5080e+002 ]; +%! +%! SYS = ss (A, B, C); +%! +%! [SYSo, INFOo] = prescale (SYS); +%! +%! [Ao, Bo, Co] = ssdata (SYSo); +%! +%! Ae = [ 0.0000000D+00 0.1000000D+05 0.0000000D+00 0.0000000D+00 0.0000000D+00 +%! -0.1580000D+03 -0.1257000D+04 0.0000000D+00 0.0000000D+00 0.0000000D+00 +%! 0.3541000D+05 0.0000000D+00 -0.1434000D+04 0.0000000D+00 -0.5330000D+03 +%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.1000000D+03 +%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 -0.1863000D+03 -0.1482000D+01 ]; +%! +%! Be = [ 0.0000000D+00 0.0000000D+00 +%! 0.1103000D+04 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.8333000D+02 ]; +%! +%! Ce = [ 0.1000000D-04 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 0.1000000D+06 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.1000000D-05 0.0000000D+00 +%! 0.6664000D-05 0.0000000D+00 -0.6200000D-07 0.0000000D+00 0.0000000D+00 +%! 0.0000000D+00 0.0000000D+00 -0.1000000D+03 0.1896000D+01 0.1508000D-01 ]; +%! +%! SCALEe = [0.1000000D-04 0.1000000D+00 0.1000000D+06 0.1000000D-05 0.1000000D-03 ]; +%! +%!assert (Ao, Ae, 1e-4); +%!assert (Bo, Be, 1e-4); +%!assert (Co, Ce, 1e-4); +%!assert (INFOo.SL.^-1, SCALEe.', 1e-4); +%!assert (INFOo.SR, SCALEe.', 1e-4); + + +## Scaling of descriptor state-space models, user function +%!shared Ao, Eo, Bo, Co, INFOo, Ae, Ee, Be, Ce, LSCALEe, RSCALEe +%! A = [ -1 0 0 0.003 +%! 0 0 0.1000 0.02 +%! 100 10 0 0.4 +%! 0 0 0 0.0]; +%! +%! E = [ 1 0.2 0 0.0 +%! 0 1 0 0.01 +%! 300 90 6 0.3 +%! 0 0 20 0.0]; +%! +%! B = [ 10 0 +%! 0 0 +%! 0 1000 +%! 10000 10000]; +%! +%! C = [ -0.1 0.0 0.001 0.0 +%! 0.0 0.01 -0.001 0.0001]; +%! +%! SYS = dss (A, B, C, [], E); +%! +%! [SYSo, INFOo] = prescale (SYS); +%! +%! [Ao, Bo, Co, ~, Eo] = dssdata (SYSo); +%! +%! Ae = [ -1.0000 0.0000 0.0000 0.3000 +%! 0.0000 0.0000 1.0000 2.0000 +%! 1.0000 0.1000 0.0000 0.4000 +%! 0.0000 0.0000 0.0000 0.0000]; +%! +%! Ee = [ 1.0000 0.2000 0.0000 0.0000 +%! 0.0000 1.0000 0.0000 1.0000 +%! 3.0000 0.9000 0.6000 0.3000 +%! 0.0000 0.0000 0.2000 0.0000 ]; +%! +%! Be = [100.0000 0.0000 +%! 0.0000 0.0000 +%! 0.0000 100.0000 +%! 100.0000 100.0000 ]; +%! +%! Ce = [ -0.0100 0.0000 0.0010 0.0000 +%! 0.0000 0.0010 -0.0010 0.0010]; +%! +%! LSCALEe = [ 10.0000 10.0000 0.1000 0.0100 ]; +%! +%! RSCALEe = [ 0.1000 0.1000 1.0000 10.0000 ]; +%! +%!assert (Ao, Ae, 1e-4); +%!assert (Eo, Ee, 1e-4); +%!assert (Bo, Be, 1e-4); +%!assert (Co, Ce, 1e-4); +%!assert (INFOo.SL, LSCALEe.', 1e-4); +%!assert (INFOo.SR, RSCALEe.', 1e-4); Modified: trunk/octave-forge/main/control/inst/@lti/sminreal.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/sminreal.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/sminreal.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -43,7 +43,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.3 +## Version: 0.4 function sys = sminreal (sys, tol = 0) @@ -110,3 +110,33 @@ endwhile endfunction + + +## ss: sminreal +%!shared B, C +%! +%! A = ss (-2, 3, 4, 5); +%! B = A / A; +%! C = sminreal (B); # no states should be removed +%! +%!assert (C.a, B.a); +%!assert (C.b, B.b); +%!assert (C.c, B.c); +%!assert (C.d, B.d); + +%!shared A, B, D, E +%! +%! A = ss (-1, 1, 1, 0); +%! B = ss (-2, 3, 4, 5); +%! C = [A, B]; +%! D = sminreal (C(:, 1)); +%! E = sminreal (C(:, 2)); +%! +%!assert (D.a, A.a); +%!assert (D.b, A.b); +%!assert (D.c, A.c); +%!assert (D.d, A.d); +%!assert (E.a, B.a); +%!assert (E.b, B.b); +%!assert (E.c, B.c); +%!assert (E.d, B.d); Modified: trunk/octave-forge/main/control/inst/@lti/zero.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/zero.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/@lti/zero.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -37,7 +37,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.1.1 +## Version: 0.2 function [zer, gain] = zero (sys) @@ -48,3 +48,118 @@ [zer, gain] = __zero__ (sys, nargout); endfunction + + +## transmission zeros of state-space models +## +## Results from the "Dark Side" 7.5 and 7.8 +## +## -13.2759 +## 12.5774 +## -0.0155 +## +## Results from Scilab 5.2.0b1 (trzeros) +## +## - 13.275931 +## 12.577369 +## - 0.0155265 +## +%!shared z, z_exp +%! A = [ -0.7 -0.0458 -12.2 0 +%! 0 -0.014 -0.2904 -0.562 +%! 1 -0.0057 -1.4 0 +%! 1 0 0 0 ]; +%! +%! B = [ -19.1 -3.1 +%! -0.0119 -0.0096 +%! -0.14 -0.72 +%! 0 0 ]; +%! +%! C = [ 0 0 -1 1 +%! 0 0 0.733 0 ]; +%! +%! D = [ 0 0 +%! 0.0768 0.1134 ]; +%! +%! sys = ss (A, B, C, D, "scaled", true); +%! z = sort (zero (sys)); +%! +%! z_exp = sort ([-13.2759; 12.5774; -0.0155]); +%! +%!assert (z, z_exp, 1e-4); + + +## transmission zeros of descriptor state-space models +%!shared z, z_exp +%! A = [ 1 0 0 0 0 0 0 0 0 +%! 0 1 0 0 0 0 0 0 0 +%! 0 0 1 0 0 0 0 0 0 +%! 0 0 0 1 0 0 0 0 0 +%! 0 0 0 0 1 0 0 0 0 +%! 0 0 0 0 0 1 0 0 0 +%! 0 0 0 0 0 0 1 0 0 +%! 0 0 0 0 0 0 0 1 0 +%! 0 0 0 0 0 0 0 0 1 ]; +%! +%! E = [ 0 0 0 0 0 0 0 0 0 +%! 1 0 0 0 0 0 0 0 0 +%! 0 1 0 0 0 0 0 0 0 +%! 0 0 0 0 0 0 0 0 0 +%! 0 0 0 1 0 0 0 0 0 +%! 0 0 0 0 1 0 0 0 0 +%! 0 0 0 0 0 0 0 0 0 +%! 0 0 0 0 0 0 1 0 0 +%! 0 0 0 0 0 0 0 1 0 ]; +%! +%! B = [ -1 0 0 +%! 0 0 0 +%! 0 0 0 +%! 0 -1 0 +%! 0 0 0 +%! 0 0 0 +%! 0 0 -1 +%! 0 0 0 +%! 0 0 0 ]; +%! +%! C = [ 0 1 1 0 3 4 0 0 2 +%! 0 1 0 0 4 0 0 2 0 +%! 0 0 1 0 -1 4 0 -2 2 ]; +%! +%! D = [ 1 2 -2 +%! 0 -1 -2 +%! 0 0 0 ]; +%! +%! sys = dss (A, B, C, D, E, "scaled", true); +%! z = zero (sys); +%! +%! z_exp = 1; +%! +%!assert (z, z_exp, 1e-4); + + +## Gain of descriptor state-space models +%!shared p, pi, z, zi, k, ki, p_tf, pi_tf, z_tf, zi_tf, k_tf, ki_tf +%! P = ss (-2, 3, 4, 5); +%! Pi = inv (P); +%! +%! p = pole (P); +%! [z, k] = zero (P); +%! +%! pi = pole (Pi); +%! [zi, ki] = zero (Pi); +%! +%! P_tf = tf (P); +%! Pi_tf = tf (Pi); +%! +%! p_tf = pole (P_tf); +%! [z_tf, k_tf] = zero (P_tf); +%! +%! pi_tf = pole (Pi_tf); +%! [zi_tf, ki_tf] = zero (Pi_tf); +%! +%!assert (p, zi, 1e-4); +%!assert (z, pi, 1e-4); +%!assert (k, inv (ki), 1e-4); +%!assert (p_tf, zi_tf, 1e-4); +%!assert (z_tf, pi_tf, 1e-4); +%!assert (k_tf, inv (ki_tf), 1e-4); Modified: trunk/octave-forge/main/control/inst/ltimodels.m =================================================================== --- trunk/octave-forge/main/control/inst/ltimodels.m 2011-11-26 12:24:32 UTC (rev 9197) +++ trunk/octave-forge/main/control/inst/ltimodels.m 2011-11-26 15:58:55 UTC (rev 9198) @@ -1,5 +1,5 @@ -## Copyright (C) 2009 Luca Favatella -## Copyright (C) 2009, 2010 Lukas Reichlin +## Copyright (C) 2009 Luca Favatella +## Copyright (C) 2009, 2010, 2011 Lukas Reichlin ## ## This file is part of LTI Syncope. ## @@ -110,380 +110,13 @@ ## TF Tests ## ============================================================================== -## tf: minreal -%!shared a, b, c, d -%! s = tf ("s"); -%! G1 = (s+1)*s*5/(s+1)/(s^2+s+1); -%! G2 = tf ([1, 1, 1], [2, 2, 2]); -%! G1min = minreal (G1); -%! G2min = minreal (G2); -%! a = G1min.num{1, 1}; -%! b = G1min.den{1, 1}; -%! c = G2min.num{1, 1}; -%! d = G2min.den{1, 1}; -%!assert (a, [5, 0], 1e-4); -%!assert (b, [1, 1, 1], 1e-4); -%!assert (c, 0.5, 1e-4); -%!assert (d, 1, 1e-4); - ## ============================================================================== ## SS Tests ## ============================================================================== -## norm ct -%!shared H2, Hinf -%! sys = ss (-1, 1, 1, 0); -%! H2 = norm (sys, 2); -%! Hinf = norm (sys, inf); -%!assert (H2, 0.7071, 1.5e-5); -%!assert (Hinf, 1, 5e-4); - -## norm dt -%!shared H2, Hinf -%! a = [ 2.417 -1.002 0.5488 -%! 2 0 0 -%! 0 0.5 0 ]; -%! b = [ 1 -%! 0 -%! 0 ]; -%! c = [-0.424 0.436 -0.4552 ]; -%! d = [ 1 ]; -%! sys = ss (a, b, c, d, 0.1); -%! H2 = norm (sys, 2); -%! Hinf = norm (sys, inf); -%!assert (H2, 1.2527, 1.5e-5); -%!assert (Hinf, 2.7, 0.1); - - -## transmission zeros of state-space models -## -## Results from the "Dark Side" 7.5 and 7.8 -## -## -13.2759 -## 12.5774 -## -0.0155 -## -## Results from Scilab 5.2.0b1 (trzeros) -## -## - 13.275931 -## 12.577369 -## - 0.0155265 -## -%!shared z, z_exp -%! A = [ -0.7 -0.0458 -12.2 0 -%! 0 -0.014 -0.2904 -0.562 -%! 1 -0.0057 -1.4 0 -%! 1 0 0 0 ]; -%! -%! B = [ -19.1 -3.1 -%! -0.0119 -0.0096 -%! -0.14 -0.72 -%! 0 0 ]; -%! -%! C = [ 0 0 -1 1 -%! 0 0 0.733 0 ]; -%! -%! D = [ 0 0 -%! 0.0768 0.1134 ]; -%! -%! sys = ss (A, B, C, D, "scaled", true); -%! z = sort (zero (sys)); -%! -%! z_exp = sort ([-13.2759; 12.5774; -0.0155]); -%! -%!assert (z, z_exp, 1e-4); - - -## transmission zeros of descriptor state-space models -%!shared z, z_exp -%! A = [ 1 0 0 0 0 0 0 0 0 -%! 0 1 0 0 0 0 0 0 0 -%! 0 0 1 0 0 0 0 0 0 -%! 0 0 0 1 0 0 0 0 0 -%! 0 0 0 0 1 0 0 0 0 -%! 0 0 0 0 0 1 0 0 0 -%! 0 0 0 0 0 0 1 0 0 -%! 0 0 0 0 0 0 0 1 0 -%! 0 0 0 0 0 0 0 0 1 ]; -%! -%! E = [ 0 0 0 0 0 0 0 0 0 -%! 1 0 0 0 0 0 0 0 0 -%! 0 1 0 0 0 0 0 0 0 -%! 0 0 0 0 0 0 0 0 0 -%! 0 0 0 1 0 0 0 0 0 -%! 0 0 0 0 1 0 0 0 0 -%! 0 0 0 0 0 0 0 0 0 -%! 0 0 0 0 0 0 1 0 0 -%! 0 0 0 0 0 0 0 1 0 ]; -%! -%! B = [ -1 0 0 -%! 0 0 0 -%! 0 0 0 -%! 0 -1 0 -%! 0 0 0 -%! 0 0 0 -%! 0 0 -1 -%! 0 0 0 -%! 0 0 0 ]; -%! -%! C = [ 0 1 1 0 3 4 0 0 2 -%! 0 1 0 0 4 0 0 2 0 -%! 0 0 1 0 -1 4 0 -2 2 ]; -%! -%! D = [ 1 2 -2 -%! 0 -1 -2 -%! 0 0 0 ]; -%! -%! sys = dss (A, B, C, D, E, "scaled", true); -%! z = zero (sys); -%! -%! z_exp = 1; -%! -%!assert (z, z_exp, 1e-4); - - -## ss: minreal (SLICOT TB01PD) -%!shared C, D -%! -%! A = ss (-2, 3, 4, 5); -%! B = A / A; -%! C = minreal (B, 1e-15); -%! D = ss (1); -%! -%!assert (C.a, D.a); -%!assert (C.b, D.b); -%!assert (C.c, D.c); -%!assert (C.d, D.d); - -%!shared M, Me -%! A = [ 1.0 2.0 0.0 -%! 4.0 -1.0 0.0 -%! 0.0 0.0 1.0 ]; -%! -%! B = [ 1.0 -%! 0.0 -%! 1.0 ]; -%! -%! C = [ 0.0 1.0 -1.0 -%! 0.0 0.0 1.0 ]; -%! -%! D = zeros (2, 1); -%! -%! sys = ss (A, B, C, D, "scaled", true); -%! sysmin = minreal (sys, 0.0); -%! [Ar, Br, Cr, Dr] = ssdata (sysmin); -%! M = [Ar, Br; Cr, Dr]; -%! -%! Ae = [ 1.0000 -1.4142 1.4142 -%! -2.8284 0.0000 1.0000 -%! 2.8284 1.0000 0.0000 ]; -%! -%! Be = [-1.0000 -%! 0.7071 -%! 0.7071 ]; -%! -%! Ce = [ 0.0000 0.0000 -1.4142 -%! 0.0000 0.7071 0.7071 ]; -%! -%! De = zeros (2, 1); -%! -%! Me = [Ae, Be; Ce, De]; -%! -%!assert (M, Me, 1e-4); - - -## dss: minreal (SLICOT TG01JD) -## FIXME: Test fails with larger ldwork in sltg01jd.cc -#%!shared Ar, Br, Cr, Dr, Er, Ae, Be, Ce, De, Ee -#%! A = [ -2 -3 0 0 0 0 0 0 0 -#%! 1 0 0 0 0 0 0 0 0 -#%! 0 0 -2 -3 0 0 0 0 0 -#%! 0 0 1 0 0 0 0 0 0 -#%! 0 0 0 0 1 0 0 0 0 -#%! 0 0 0 0 0 1 0 0 0 -#%! 0 0 0 0 0 0 1 0 0 -#%! 0 0 0 0 0 0 0 1 0 -#%! 0 0 0 0 0 0 0 0 1 ]; -#%! -#%! E = [ 1 0 0 0 0 0 0 0 0 -#%! 0 1 0 0 0 0 0 0 0 -#%! 0 0 1 0 0 0 0 0 0 -#%! 0 0 0 1 0 0 0 0 0 -#%! 0 0 0 0 0 0 0 0 0 -#%! 0 0 0 0 1 0 0 0 0 -#%! 0 0 0 0 0 0 0 0 0 -#%! 0 0 0 0 0 0 1 0 0 -#%! 0 0 0 0 0 0 0 1 0 ]; -#%! -#%! B = [ 1 0 -#%! 0 0 -#%! 0 1 -#%! 0 0 -#%! -1 0 -#%! 0 0 -#%! 0 -1 -#%! 0 0 -#%! 0 0 ]; -#%! -#%! C = [ 1 0 1 -3 0 1 0 2 0 -#%! 0 1 1 3 0 1 0 0 1 ]; -#%! -#%! D = zeros (2, 2); -#%! -#%! sys = dss (A, B, C, D, E, "scaled", true); -#%! sysmin = minreal (sys, 0.0); -#%! [Ar, Br, Cr, Dr, Er] = dssdata (sysmin); -#%! -#%! Ae = [ 1.0000 -0.0393 -0.0980 -0.1066 0.0781 -0.2330 0.0777 -#%! 0.0000 1.0312 0.2717 0.2609 -0.1533 0.6758 -0.3553 -#%! 0.0000 0.0000 1.3887 0.6699 -0.4281 1.6389 -0.7615 -#%! 0.0000 0.0000 0.0000 -1.2147 0.2423 -0.9792 0.4788 -#%! 0.0000 0.0000 0.0000 0.0000 -1.0545 0.5035 -0.2788 -#%! 0.0000 0.0000 0.0000 0.0000 0.0000 1.6355 -0.4323 -#%! 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 1.0000 ]; -#%! -#%! Ee = [ 0.4100 0.2590 0.5080 -0.3109 0.0705 0.1429 -0.1477 -#%! -0.7629 -0.3464 0.0992 -0.3007 0.0619 0.2483 -0.0152 -#%! 0.1120 -0.2124 -0.4184 -0.1288 0.0569 -0.4213 -0.6182 -#%! 0.0000 0.1122 -0.0039 0.2771 -0.0758 0.0975 0.3923 -#%! 0.0000 0.0000 0.3708 -0.4290 0.1006 0.1402 -0.2699 -#%! 0.0000 0.0000 0.0000 0.0000 0.9458 -0.2211 0.2378 -#%! 0.0000 0.0000 0.0000 0.5711 0.2648 0.5948 -0.5000 ]; -#%! -#%! Be = [ -0.5597 0.2363 -#%! -0.4843 -0.0498 -#%! -0.4727 -0.1491 -#%! 0.1802 1.1574 -#%! 0.5995 0.1556 -#%! -0.1729 -0.3999 -#%! 0.0000 0.2500 ]; -#%! -#%! Ce = [ 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 4.0000 -#%! 0.0000 0.0000 0.0000 0.0000 0.0000 3.1524 -1.7500 ]; -#%! -#%! De = zeros (2, 2); -#%! -#%!assert (Ar, Ae, 1e-4); -#%!assert (Br, Be, 1e-4); -#%!assert (Cr, Ce, 1e-4); -#%!assert (Dr, De, 1e-4); -#%!assert (Er, Ee, 1e-4); - - -## ss: sminreal -%!shared B, C -%! -%! A = ss (-2, 3, 4, 5); -%! B = A / A; -%! C = sminreal (B); # no states should be removed -%! -%!assert (C.a, B.a); -%!assert (C.b, B.b); -%!assert (C.c, B.c); -%!assert (C.d, B.d); - -%!shared A, B, D, E -%! -%! A = ss (-1, 1, 1, 0); -%! B = ss (-2, 3, 4, 5); -%! C = [A, B]; -%! D = sminreal (C(:, 1)); -%! E = sminreal (C(:, 2)); -%! -%!assert (D.a, A.a); -%!assert (D.b, A.b); -%!assert (D.c, A.c); -%!assert (D.d, A.d); -%!assert (E.a, B.a); -%!assert (E.b, B.b); -%!assert (E.c, B.c); -%!assert (E.d, B.d); - - -## mtimes -%!shared sysmat, sysmat_exp -%! sys1 = ss ([0, 1; -3, -2], [0; 1], [-5, 1], [2]); -%! sys2 = ss ([-10], [1], [-40], [5]); -%! sys3 = sys2 * sys1; -%! [A, B, C, D] = ssdata (sys3); -%! sysmat = [A, B; C, D]; -%! A_exp = [ -10 -5 1 -%! 0 0 1 -%! 0 -3 -2 ]; -%! B_exp = [ 2 -%! 0 -%! 1 ]; -%! C_exp = [ -40 -25 5 ]; -%! D_exp = [ 10 ]; -%! sysmat_exp = [A_exp, B_exp; C_exp, D_exp]; -%!assert (sysmat, sysmat_exp) - - -## inverse of state-space models -## test from SLICOT AB07ND -## result differs intentionally from a commercial -## implementation of an octave-like language -%!shared M, Me -%! A = [ 1.0 2.0 0.0 -%! 4.0 -1.0 0.0 -%! 0.0 0.0 1.0 ]; -%! -%! B = [ 1.0 0.0 -%! 0.0 1.0 -%! 1.0 0.0 ]; -%! -%! C = [ 0.0 1.0 -1.0 -%! 0.0 0.0 1.0 ]; -%! -%! D = [ 4.0 0.0 -%! 0.0 1.0 ]; -%! -%! sys = ss (A, B, C, D); -%! sysinv = inv (sys); -%! [Ai, Bi, Ci, Di] = ssdata (sysinv); -%! M = [Ai, Bi; Ci, Di]; -%! -%! Ae = [ 1.0000 1.7500 0.2500 -%! 4.0000 -1.0000 -1.0000 -%! 0.0000 -0.2500 1.2500 ]; -%! -%! Be = [-0.2500 0.0000 -%! 0.0000 -1.0000 -%! -0.2500 0.0000 ]; -%! -%! Ce = [ 0.0000 0.2500 -0.2500 -%! 0.0000 0.0000 1.0000 ]; -%! -%! De = [ 0.2500 0.0000 -%! 0.0000 1.0000 ]; -%! -%! Me = [Ae, Be; Ce, De]; # Me = [Ae, -Be; -Ce, De]; -%! -%!assert (M, Me, 1e-4); - - -## sensitivity function -## Note the correct physical meaning of the states. -## Test would fail on a commercial octave clone -## because of wrong signs of matrices B and C. -## NOTE: Don't use T = I - S for complementary sensitivity, -## use T = feedback (L) instead! -%!shared S1, S2 -%! P = ss (-2, 3, 4, 5); # meaningless numbers -%! C = ss (-1, 1, 1, 0); # ditto -%! L = P * C; -%! I = eye (size (L)); -%! S1 = feedback (I, L*-I, "+"); # draw a block diagram for better understanding -%! S2 = inv (I + L); -%!assert (S1.a, S2.a, 1e-4); -%!assert (S1.b, S2.b, 1e-4); -%!assert (S1.c, S2.c, 1e-4); -%!assert (S1.d, S2.d, 1e-4); - - ## staircase (SLICOT AB01OD) %!shared Ac, Bc, Ace, Bce %! A = [ 17.0 24.0 1.0 8.0 15.0 @@ -699,491 +332,6 @@ %!assert (nobsv, nobsv_e); -## Cascade inter-connection of two systems in state-space form -## Test from SLICOT AB05MD -## TODO: order of united state vector: consistency vs. compatibility? -#%!shared M, Me -#%! A1 = [ 1.0 0.0 -1.0 -#%! 0.0 -1.0 1.0 -#%! 1.0 1.0 2.0 ]; -#%! -#%! B1 = [ 1.0 1.0 0.0 -#%! 2.0 0.0 1.0 ].'; -#%! -#%! C1 = [ 3.0 -2.0 1.0 -#%! 0.0 1.0 0.0 ]; -#%! -#%! D1 = [ 1.0 0.0 -#%! 0.0 1.0 ]; -#%! -#%! A2 = [-3.0 0.0 0.0 -#%! 1.0 0.0 1.0 -#%! 0.0 -1.0 2.0 ]; -#%! -#%! B2 = [ 0.0 -1.0 0.0 -#%! 1.0 0.0 2.0 ].'; -#%! -#%! C2 = [ 1.0 1.0 0.0 -#%! 1.0 1.0 -1.0 ]; -#%! -#%! D2 = [ 1.0 1.0 -#%! 0.0 1.0 ]; -#%! -#%! sys1 = ss (A1, B1, C1, D1); -#%! sys2 = ss (A2, B2, C2, D2); -#%! sys = sys2 * sys1; -#%! [A, B, C, D] = ssdata (sys); -#%! M = [A, B; C, D]; -#%! -#%! Ae = [ 1.0000 0.0000 -1.0000 0.0000 0.0000 0.0000 -#%! 0.0000 -1.0000 1.0000 0.0000 0.0000 0.0000 -#%! 1.0000 1.0000 2.0000 0.0000 0.0000 0.0000 -#%! 0.0000 1.0000 0.0000 -3.0000 0.0000 0.0000 -#%! -3.0000 2.0000 -1.0000 1.0000 0.0000 1.0000 -#%! 0.0000 2.0000 0.0000 0.0000 -1.0000 2.0000 ]; -#%! -#%! Be = [ 1.0000 2.0000 -#%! 1.0000 0.0000 -#%! 0.0000 1.0000 -#%! 0.0000 1.0000 -#%! -1.0000 0.0000 -#%! 0.0000 2.0000 ]; -#%! -#%! Ce = [ 3.0000 -1.0000 1.0000 1.0000 1.0000 0.0000 -#%! 0.0000 1.0000 0.0000 1.0000 1.0000 -1.0000 ]; -#%! -#%! De = [ 1.0000 1.0000 -#%! 0.0000 1.0000 ]; -#%! -#%! Me = [Ae, Be; Ce, De]; -#%! -#%!assert (M, Me, 1e-4); - - -## Feedback inter-connection of two systems in state-space form -## Test from SLICOT AB05ND -%!shared M, Me -%! A1 = [ 1.0 0.0 -1.0 -%! 0.0 -1.0 1.0 -%! 1.0 1.0 2.0 ]; -%! -%! B1 = [ 1.0 1.0 0.0 -%! 2.0 0.0 1.0 ].'; -%! -%! C1 = [ 3.0 -2.0 1.0 -%! 0.0 1.0 0.0 ]; -%! -%! D1 = [ 1.0 0.0 -%! 0.0 1.0 ]; -%! -%! A2 = [-3.0 0.0 0.0 -%! 1.0 0.0 1.0 -%! 0.0 -1.0 2.0 ]; -%! -%! B2 = [ 0.0 -1.0 0.0 -%! 1.0 0.0 2.0 ].'; -%! -%! C2 = [ 1.0 1.0 0.0 -%! 1.0 1.0 -1.0 ]; -%! -%! D2 = [ 1.0 1.0 -%! 0.0 1.0 ]; -%! -%! sys1 = ss (A1, B1, C1, D1); -%! sys2 = ss (A2, B2, C2, D2); -%! sys = feedback (sys1, sys2); -%! [A, B, C, D] = ssdata (sys); -%! M = [A, B; C, D]; -%! -%! Ae = [-0.5000 -0.2500 -1.5000 -1.2500 -1.2500 0.7500 -%! -1.5000 -0.2500 0.5000 -0.2500 -0.2500 -0.2500 -%! 1.0000 0.5000 2.0000 -0.5000 -0.5000 0.5000 -%! 0.0000 0.5000 0.0000 -3.5000 -0.5000 0.5000 -%! -1.5000 1.2500 -0.5000 1.2500 0.2500 1.2500 -%! 0.0000 1.0000 0.0000 -1.0000 -2.0000 3.0000 ]; -%! -%! Be = [ 0.5000 0.7500 -%! 0.5000 -0.2500 -%! 0.0000 0.5000 -%! 0.0000 0.5000 -%! -0.5000 0.2500 -%! 0.0000 1.0000 ]; -%! -%! Ce = [ 1.5000 -1.2500 0.5000 -0.2500 -0.2500 -0.2500 -%! 0.0000 0.5000 0.0000 -0.5000 -0.5000 0.5000 ]; -%! -%! De = [ 0.5000 -0.2500 -%! 0.0000 0.5000 ]; -%! -%! Me = [Ae, Be; Ce, De]; -%! -%!assert (M, Me, 1e-4); - - -## Rowwise concatenation of two systems in state-space form -## Test from SLICOT AB05OD -%!shared M, Me -%! A1 = [ 1.0 0.0 -1.0 -%! 0.0 -1.0 1.0 -%! 1.0 1.0 2.0 ]; -%! -%! B1 = [ 1.0 1.0 0.0 -%! 2.0 0.0 1.0 ].'; -%! -%! C1 = [ 3.0 -2.0 1.0 -%! 0.0 1.0 0.0 ]; -%! -%! D1 = [ 1.0 0.0 -%! 0.0 1.0 ]; -%! -%! A2 = [-3.0 0.0 0.0 -%! 1.0 0.0 1.0 -%! 0.0 -1.0 2.0 ]; -%! -%! B2 = [ 0.0 -1.0 0.0 -%! 1.0 0.0 2.0 ].'; -%! -%! C2 = [ 1.0 1.0 0.0 -%! 1.0 1.0 -1.0 ]; -%! -%! D2 = [ 1.0 1.0 -%! 0.0 1.0 ]; -%! -%! sys1 = ss (A1, B1, C1, D1); -%! sys2 = ss (A2, B2, C2, D2); -%! sys = [sys1, sys2]; -%! [A, B, C, D] = ssdata (sys); -%! M = [A, B; C, D]; -%! -%! Ae = [ 1.0000 0.0000 -1.0000 0.0000 0.0000 0.0000 -%! 0.0000 -1.0000 1.0000 0.0000 0.0000 0.0000 -%! 1.0000 1.0000 2.0000 0.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 -3.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 1.0000 0.0000 1.0000 -%! 0.0000 0.0000 0.0000 0.0000 -1.0000 2.0000 ]; -%! -%! Be = [ 1.0000 2.0000 0.0000 0.0000 -%! 1.0000 0.0000 0.0000 0.0000 -%! 0.0000 1.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 1.0000 -%! 0.0000 0.0000 -1.0000 0.0000 -%! 0.0000 0.0000 0.0000 2.0000 ]; -%! -%! Ce = [ 3.0000 -2.0000 1.0000 1.0000 1.0000 0.0000 -%! 0.0000 1.0000 0.0000 1.0000 1.0000 -1.0000 ]; -%! -%! De = [ 1.0000 0.0000 1.0000 1.0000 -%! 0.0000 1.0000 0.0000 1.0000 ]; -%! -%! Me = [Ae, Be; Ce, De]; -%! -%!assert (M, Me, 1e-4); - - -## Parallel inter-connection of two systems in state-space form -## Test from SLICOT AB05PD -%!shared M, Me -%! A1 = [ 1.0 0.0 -1.0 -%! 0.0 -1.0 1.0 -%! 1.0 1.0 2.0 ]; -%! -%! B1 = [ 1.0 1.0 0.0 -%! 2.0 0.0 1.0 ].'; -%! -%! C1 = [ 3.0 -2.0 1.0 -%! 0.0 1.0 0.0 ]; -%! -%! D1 = [ 1.0 0.0 -%! 0.0 1.0 ]; -%! -%! A2 = [-3.0 0.0 0.0 -%! 1.0 0.0 1.0 -%! 0.0 -1.0 2.0 ]; -%! -%! B2 = [ 0.0 -1.0 0.0 -%! 1.0 0.0 2.0 ].'; -%! -%! C2 = [ 1.0 1.0 0.0 -%! 1.0 1.0 -1.0 ]; -%! -%! D2 = [ 1.0 1.0 -%! 0.0 1.0 ]; -%! -%! sys1 = ss (A1, B1, C1, D1); -%! sys2 = ss (A2, B2, C2, D2); -%! sys = sys1 + sys2; -%! [A, B, C, D] = ssdata (sys); -%! M = [A, B; C, D]; -%! -%! Ae = [ 1.0000 0.0000 -1.0000 0.0000 0.0000 0.0000 -%! 0.0000 -1.0000 1.0000 0.0000 0.0000 0.0000 -%! 1.0000 1.0000 2.0000 0.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 -3.0000 0.0000 0.0000 -%! 0.0000 0.0000 0.0000 1.0000 0.0000 1.0000 -%! 0.0000 0.0000 0.0000 0.0000 -1.0000 2.0000 ]; -%! -%! Be = [ 1.0000 2.0000 -%! 1.0000 0.0000 -%! 0.0000 1.0000 -%! 0.0000 1.0000 -%! -1.0000 0.0000 -%! 0.0000 2.0000 ]; -%! -%! Ce = [ 3.0000 -2.0000 1.0000 1.0000 1.0000 0.0000 -%! 0.0000 1.0000 0.0000 1.0000 1.0000 -1.0000 ]; -%! -%! De = [ 2.0000 1.0000 -%! 0.0000 2.0000 ]; -%! -%! Me = [Ae, Be; Ce, De]; -%! -%!assert (M, Me, 1e-4); - - -## Gain of descriptor state-space models -%!shared p, pi, z, zi, k, ki, p_tf, pi_tf, z_tf, zi_tf, k_tf, ki_tf -%! P = ss (-2, 3, 4, 5); -%! Pi = inv (P); -%! -%! p = pole (P); -%! [z, k] = zero (P); -%! -%! pi = pole (Pi); -%! [zi, ki] = zero (Pi); -%! -%! P_tf = tf (P); -%! Pi_tf = tf (Pi); -%! -%! p_tf = pole (P_tf); -%! [z_tf, k_tf] = zero (P_tf); -%! -%! pi_tf = pole (Pi_tf); -%! [zi_tf, ki_tf] = zero (Pi_tf); -%! -%!assert (p, zi, 1e-4); -%!assert (z, pi, 1e-4); -%!assert (k, inv (ki), 1e-4); -%!assert (p_tf, zi_tf, 1e-4); -%!assert (z_tf, pi_tf, 1e-4); -%!assert (k_tf, inv (ki_tf), 1e-4); - - -## Scaling of state-space models, direct access to TB01ID -%!shared Ao, Bo, Co, SCALEo, MAXREDo, Ae, Be, Ce, SCALEe, MAXREDe -%! A = [ 0.0 1.0000e+000 0.0 0.0 0.0 -%! -1.5800e+006 -1.2570e+003 0.0 0.0 0.0 -%! 3.5410e+014 0.0 -1.4340e+003 0.0 -5.3300e+011 -%! 0.0 0.0 0.0 0.0 1.0000e+000 -%! 0.0 0.0 0.0 -1.8630e+004 -1.4820e+000 ]; -%! -%! B = [ 0.0 0.0 -%! 1.1030e+002 0.0 -%! 0.0 0.0 -%! 0.0 0.0 -%! 0.0 8.3330e-003 ]; -%! -%! C = [ 1.0000e+000 0.0 0.0 0.0 0.0 -%! 0.0 0.0 1.0000e+000 0.0 0.0 -%! 0.0 0.0 0.0 1.0000e+000 0.0 -%! 6.6640e-001 0.0 -6.2000e-013 0.0 0.0 -%! 0.0 0.0 -1.0000e-003 1.8960e+006 1.5080e+002 ]; -%! -%! MAXRED = 0.0; -%! -%! [Ao, Bo, Co, MAXREDo, SCALEo] = sltb01id (A, B, C, MAXRED); -%! -%! Ae = [ 0.0000000D+00 0.1000000D+05 0.0000000D+00 0.0000000D+00 0.0000000D+00 -%! -0.1580000D+03 -0.1257000D+04 0.0000000D+00 0.0000000D+00 0.0000000D+00 -%! 0.3541000D+05 0.0000000D+00 -0.1434000D+04 0.0000000D+00 -0.5330000D+03 -%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.1000000D+03 -%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 -0.1863000D+03 -0.1482000D+01 ]; -%! -%! Be = [ 0.0000000D+00 0.0000000D+00 -%! 0.1103000D+04 0.0000000D+00 -%! 0.0000000D+00 0.0000000D+00 -%! 0.0000000D+00 0.0000000D+00 -%! 0.0000000D+00 0.8333000D+02 ]; -%! -%! Ce = [ 0.1000000D-04 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.0000000D+00 -%! 0.0000000D+00 0.0000000D+00 0.1000000D+06 0.0000000D+00 0.0000000D+00 -%! 0.0000000D+00 0.0000000D+00 0.0000000D+00 0.1000000D-05 0.0000000D+00 -%! 0.6664000D-05 0.0000000D+00 -0.6200000D-07 0.0000000D+00 0.0000000D+00 -%! 0.0000000D+00 0.0000000D+00 -0.1000000D+03 0.1896000D+01 0.1508000D-01 ]; -%! -%! SCALEe = [0.1000000D-04 0.1000000D+00 0.1000000D+06 0.1000000D-05 0.1000000D-03 ]; -%! -%! MAXREDe = 0.3488E+10; -%! -%!assert (Ao, Ae, 1e-4); -%!assert (Bo, Be, 1e-4); -%!assert (Co, Ce, 1e-4); -%!assert (MAXREDo, MAXREDe, 1e6); -%!assert (SCALEo, SCALEe.', 1e-4); - - -## Scaling of descriptor state-space models, direct access to TG01AD -%!shared Ao, Eo, Bo, Co, LSCALEo, RSCALEo, Ae, Ee, Be, Ce, LSCALEe, RSCALEe -%! A = [ -1 0 0 0.003 -%! 0 ... [truncated message content] |
From: <par...@us...> - 2011-12-06 20:37:36
|
Revision: 9293 http://octave.svn.sourceforge.net/octave/?rev=9293&view=rev Author: paramaniac Date: 2011-12-06 20:37:29 +0000 (Tue, 06 Dec 2011) Log Message: ----------- control: replace "" by ' Modified Paths: -------------- trunk/octave-forge/main/control/inst/@frd/display.m trunk/octave-forge/main/control/inst/@lti/set.m trunk/octave-forge/main/control/inst/@ss/__set__.m trunk/octave-forge/main/control/inst/@tf/display.m trunk/octave-forge/main/control/inst/gensig.m Modified: trunk/octave-forge/main/control/inst/@frd/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/display.m 2011-12-06 20:36:51 UTC (rev 9292) +++ trunk/octave-forge/main/control/inst/@frd/display.m 2011-12-06 20:37:29 UTC (rev 9293) @@ -35,7 +35,7 @@ disp (""); for k = 1 : m - disp (["Frequency response \"", sysname, "\" from input \"", inname{k}, "\" to output ..."]); + disp (["Frequency response '", sysname, "' from input '", inname{k}, "' to output ..."]); disp (""); __disp_resp__ (sys.H(:,k,:), w, outname); endfor Modified: trunk/octave-forge/main/control/inst/@lti/set.m =================================================================== --- trunk/octave-forge/main/control/inst/@lti/set.m 2011-12-06 20:36:51 UTC (rev 9292) +++ trunk/octave-forge/main/control/inst/@lti/set.m 2011-12-06 20:37:29 UTC (rev 9293) @@ -43,7 +43,7 @@ elseif (nargout == 0) # set (sys, "prop1", val1, ...) - warning ("lti: set: use sys = get (sys, ""property1"", ...) to save changes"); + warning ("lti: set: use sys = get (sys, 'property1', ...) to save changes"); warning (" octave does not support pass by reference"); else # sys = set (sys, "prop1", val1, ...) @@ -68,7 +68,7 @@ case {"tsam", "ts"} if (issample (val, -1)) sys.tsam = val; - warning ("lti: set: use the editing of property ""%s"" with caution", prop); + warning ("lti: set: use the editing of property '%s' with caution", prop); warning (" it may lead to corrupted models"); else error ("lti: set: invalid sampling time"); @@ -79,7 +79,7 @@ if (ischar (val)) sys.name = val; else - error ("lti: set: property ""name"" requires a string"); + error ("lti: set: property 'name' requires a string"); endif case "notes" @@ -88,7 +88,7 @@ elseif (ischar (val)) sys.notes = {val}; else - error ("lti: set: property ""notes"" requires string or cell of strings"); + error ("lti: set: property 'notes' requires string or cell of strings"); endif case "userdata" Modified: trunk/octave-forge/main/control/inst/@ss/__set__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__set__.m 2011-12-06 20:36:51 UTC (rev 9292) +++ trunk/octave-forge/main/control/inst/@ss/__set__.m 2011-12-06 20:37:29 UTC (rev 9293) @@ -57,7 +57,7 @@ if (isscalar (val)) sys.scaled = logical (val); else - error ("ss: set: property ""scaled"" must be a logical value"); + error ("ss: set: property 'scaled' must be a logical value"); endif otherwise Modified: trunk/octave-forge/main/control/inst/@tf/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/display.m 2011-12-06 20:36:51 UTC (rev 9292) +++ trunk/octave-forge/main/control/inst/@tf/display.m 2011-12-06 20:37:29 UTC (rev 9293) @@ -33,7 +33,7 @@ disp (""); for nu = 1 : m - disp (["Transfer function \"", sysname, "\" from input \"", inname{nu}, "\" to output ..."]); + 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}); Modified: trunk/octave-forge/main/control/inst/gensig.m =================================================================== --- trunk/octave-forge/main/control/inst/gensig.m 2011-12-06 20:36:51 UTC (rev 9292) +++ trunk/octave-forge/main/control/inst/gensig.m 2011-12-06 20:37:29 UTC (rev 9293) @@ -92,7 +92,7 @@ case "pu" u = double (rem (t, tau) < (1 - 1000*eps) * tsam); otherwise - error ("gensig: ""%s"" is an invalid signal type", sigtype); + error ("gensig: '%s' is an invalid signal type", sigtype); endswitch endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-07 15:17:21
|
Revision: 9300 http://octave.svn.sourceforge.net/octave/?rev=9300&view=rev Author: paramaniac Date: 2011-12-07 15:17:11 +0000 (Wed, 07 Dec 2011) Log Message: ----------- control: solve problem with purely imaginary poles and zeros 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/sigma.m Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2011-12-07 13:40:26 UTC (rev 9299) +++ trunk/octave-forge/main/control/inst/bode.m 2011-12-07 15:17:11 UTC (rev 9300) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -45,7 +45,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.3 function [mag_r, pha_r, w_r] = bode (sys, w = []) @@ -78,6 +78,10 @@ subplot (2, 1, 1) semilogx (w, mag_db) + ax = axis; + if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros + ax_vec_mag(3:4) = ax(3:4); + endif axis (ax_vec_mag) grid ("on") title (["Bode Diagram of ", inputname(1)]) Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2011-12-07 13:40:26 UTC (rev 9299) +++ trunk/octave-forge/main/control/inst/bodemag.m 2011-12-07 15:17:11 UTC (rev 9300) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -43,7 +43,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.3 function [mag_r, w_r] = bodemag (sys, w = []) @@ -72,6 +72,10 @@ endif semilogx (w, mag_db) + ax = axis; + if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros + ax_vec_mag(3:4) = ax(3:4); + endif axis (ax_vec_mag) grid ("on") title (["Bode Magnitude Diagram of ", inputname(1)]) Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2011-12-07 13:40:26 UTC (rev 9299) +++ trunk/octave-forge/main/control/inst/nichols.m 2011-12-07 15:17:11 UTC (rev 9300) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -45,7 +45,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.3 function [mag_r, pha_r, w_r] = nichols (sys, w = []) @@ -66,6 +66,10 @@ ax_vec = __axis_limits__ ([reshape(pha, [], 1), reshape(mag_db, [], 1)]); plot (pha, mag_db) + ax = axis; + if (any (isinf (ax_vec))) # catch case purely imaginary poles or zeros + ax_vec(3:4) = ax(3:4); + endif axis (ax_vec) grid ("on") title (["Nichols Chart of ", inputname(1)]) Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2011-12-07 13:40:26 UTC (rev 9299) +++ trunk/octave-forge/main/control/inst/sigma.m 2011-12-07 15:17:11 UTC (rev 9300) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2011 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -57,7 +57,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2009 -## Version: 0.4 +## Version: 0.5 function [sv_r, w_r] = sigma (sys, w = [], resptype = 0) @@ -91,6 +91,10 @@ ## plot results semilogx (w, sv_db, "b") + ax = axis; + if (any (isinf (ax_vec))) # catch case purely imaginary poles or zeros + ax_vec(3:4) = ax(3:4); + endif axis (ax_vec) title (["Singular Values of ", inputname(1)]) xlabel (xl_str) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-11 15:37:22
|
Revision: 9365 http://octave.svn.sourceforge.net/octave/?rev=9365&view=rev Author: paramaniac Date: 2011-12-11 15:37:14 +0000 (Sun, 11 Dec 2011) Log Message: ----------- control: rework axis limits of plotting Modified Paths: -------------- trunk/octave-forge/main/control/inst/bode.m Added Paths: ----------- trunk/octave-forge/main/control/inst/__plot_margin__.m Added: trunk/octave-forge/main/control/inst/__plot_margin__.m =================================================================== --- trunk/octave-forge/main/control/inst/__plot_margin__.m (rev 0) +++ trunk/octave-forge/main/control/inst/__plot_margin__.m 2011-12-11 15:37:14 UTC (rev 9365) @@ -0,0 +1,61 @@ +## Copyright (C) 1998, 2000, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## +## +## This program is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __plot_margin__ (@var{axdata}) +## Determine axis limits for 2-D data (column vectors); leaves a 10% +## margin around the plots. +## Inserts margins of +/- 0.1 if data is one-dimensional +## (or a single point). +## +## @strong{Input} +## @table @var +## @item axdata +## @var{n} by 2 matrix of data [@var{x}, @var{y}]. +## @end table +## +## @strong{Output} +## @table @var +## @item axvec +## Vector of axis limits appropriate for call to @command{axis} function. +## @end table +## @end deftypefn + +function axvec = __plot_margin__ (axdata) + + ## compute axis limits + minv = axdata(1); + maxv = axdata(2); + delv = (maxv-minv)/2; # breadth of the plot + midv = (minv + maxv)/2; # midpoint of the plot + axmid = [midv, midv]; + axdel = [-0.1, 0.1]; # default plot width (if less than 2-d data) + if (delv == 0) + if (midv != 0) + axdel = [-0.1*midv, 0.1*midv]; + endif + else + ## they're at least one-dimensional + tolv = max(1e-8, 1e-8*abs(midv)); + if (abs (delv) >= tolv) + axdel = 1.1*[-delv,delv]; + endif + endif + axvec = axmid + axdel; + +endfunction Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2011-12-11 15:04:33 UTC (rev 9364) +++ trunk/octave-forge/main/control/inst/bode.m 2011-12-11 15:37:14 UTC (rev 9365) @@ -64,12 +64,6 @@ if (! nargout) mag_db = 20 * log10 (mag); - wv = [min(w), max(w)]; - ax_vec_mag = __axis_limits__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); - ax_vec_mag(1:2) = wv; - ax_vec_pha = __axis_limits__ ([reshape(w, [], 1), reshape(pha, [], 1)]); - ax_vec_pha(1:2) = wv; - if (isct (sys)) xl_str = "Frequency [rad/s]"; else @@ -78,18 +72,16 @@ subplot (2, 1, 1) semilogx (w, mag_db) - ax = axis; - if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros - ax_vec_mag(3:4) = ax(3:4); - endif - axis (ax_vec_mag) + axis ("tight") + ylim (__plot_margin__ (ylim)); grid ("on") title (["Bode Diagram of ", inputname(1)]) ylabel ("Magnitude [dB]") subplot (2, 1, 2) semilogx (w, pha) - axis (ax_vec_pha) + axis ("tight") + ylim (__plot_margin__ (ylim)); grid ("on") xlabel (xl_str) ylabel ("Phase [deg]") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-11 16:49:45
|
Revision: 9366 http://octave.svn.sourceforge.net/octave/?rev=9366&view=rev Author: paramaniac Date: 2011-12-11 16:49:39 +0000 (Sun, 11 Dec 2011) Log Message: ----------- control: rework axis limits of plotting (2) Modified Paths: -------------- trunk/octave-forge/main/control/inst/__plot_margin__.m trunk/octave-forge/main/control/inst/bode.m Modified: trunk/octave-forge/main/control/inst/__plot_margin__.m =================================================================== --- trunk/octave-forge/main/control/inst/__plot_margin__.m 2011-12-11 15:37:14 UTC (rev 9365) +++ trunk/octave-forge/main/control/inst/__plot_margin__.m 2011-12-11 16:49:39 UTC (rev 9366) @@ -38,6 +38,11 @@ function axvec = __plot_margin__ (axdata) + if (any (isinf (axdata))) + axvec = "tight"; + return; + endif + ## compute axis limits minv = axdata(1); maxv = axdata(2); @@ -45,6 +50,7 @@ midv = (minv + maxv)/2; # midpoint of the plot axmid = [midv, midv]; axdel = [-0.1, 0.1]; # default plot width (if less than 2-d data) + if (delv == 0) if (midv != 0) axdel = [-0.1*midv, 0.1*midv]; @@ -56,6 +62,7 @@ axdel = 1.1*[-delv,delv]; endif endif + axvec = axmid + axdel; endfunction Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2011-12-11 15:37:14 UTC (rev 9365) +++ trunk/octave-forge/main/control/inst/bode.m 2011-12-11 16:49:39 UTC (rev 9366) @@ -73,7 +73,7 @@ subplot (2, 1, 1) semilogx (w, mag_db) axis ("tight") - ylim (__plot_margin__ (ylim)); + %ylim (__plot_margin__ (ylim)); grid ("on") title (["Bode Diagram of ", inputname(1)]) ylabel ("Magnitude [dB]") @@ -81,7 +81,7 @@ subplot (2, 1, 2) semilogx (w, pha) axis ("tight") - ylim (__plot_margin__ (ylim)); + %ylim (__plot_margin__ (ylim)); grid ("on") xlabel (xl_str) ylabel ("Phase [deg]") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-11 19:06:00
|
Revision: 9367 http://octave.svn.sourceforge.net/octave/?rev=9367&view=rev Author: paramaniac Date: 2011-12-11 19:05:54 +0000 (Sun, 11 Dec 2011) Log Message: ----------- control: fix axis problem Modified Paths: -------------- trunk/octave-forge/main/control/inst/bode.m Added Paths: ----------- trunk/octave-forge/main/control/inst/__axis_margin__.m Removed Paths: ------------- trunk/octave-forge/main/control/inst/__plot_margin__.m Copied: trunk/octave-forge/main/control/inst/__axis_margin__.m (from rev 9366, trunk/octave-forge/main/control/inst/__plot_margin__.m) =================================================================== --- trunk/octave-forge/main/control/inst/__axis_margin__.m (rev 0) +++ trunk/octave-forge/main/control/inst/__axis_margin__.m 2011-12-11 19:05:54 UTC (rev 9367) @@ -0,0 +1,63 @@ +## Copyright (C) 1998, 2000, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## +## +## This program is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} __axis_margin__ (@var{axdata}) +## Determine axis limits for 2-D data (column vectors); leaves a 10% +## margin around the plots. +## Inserts margins of +/- 0.1 if data is one-dimensional +## (or a single point). +## +## @strong{Input} +## @table @var +## @item axdata +## @var{n} by 2 matrix of data [@var{x}, @var{y}]. +## @end table +## +## @strong{Output} +## @table @var +## @item axvec +## Vector of axis limits appropriate for call to @command{axis} function. +## @end table +## @end deftypefn + +function axvec = __axis_margin__ (axdata, left, right) + + ## compute axis limits + minv = axdata(3); + maxv = axdata(4); + delv = (maxv-minv)/2; # breadth of the plot + midv = (minv + maxv)/2; # midpoint of the plot + axmid = [midv, midv]; + axdel = [-0.1, 0.1]; # default plot width (if less than 2-d data) + + if (delv == 0) + if (midv != 0) + axdel = [-0.1*midv, 0.1*midv]; + endif + else + ## they're at least one-dimensional + tolv = max(1e-8, 1e-8*abs(midv)); + if (abs (delv) >= tolv) + axdel = 1.1*[-delv,delv]; + endif + endif + + axvec = [left, right, axmid + axdel]; + +endfunction Deleted: trunk/octave-forge/main/control/inst/__plot_margin__.m =================================================================== --- trunk/octave-forge/main/control/inst/__plot_margin__.m 2011-12-11 16:49:39 UTC (rev 9366) +++ trunk/octave-forge/main/control/inst/__plot_margin__.m 2011-12-11 19:05:54 UTC (rev 9367) @@ -1,68 +0,0 @@ -## Copyright (C) 1998, 2000, 2004, 2005, 2007 -## Auburn University. All rights reserved. -## -## -## This program is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; see the file COPYING. If not, see -## <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Function File} {} __plot_margin__ (@var{axdata}) -## Determine axis limits for 2-D data (column vectors); leaves a 10% -## margin around the plots. -## Inserts margins of +/- 0.1 if data is one-dimensional -## (or a single point). -## -## @strong{Input} -## @table @var -## @item axdata -## @var{n} by 2 matrix of data [@var{x}, @var{y}]. -## @end table -## -## @strong{Output} -## @table @var -## @item axvec -## Vector of axis limits appropriate for call to @command{axis} function. -## @end table -## @end deftypefn - -function axvec = __plot_margin__ (axdata) - - if (any (isinf (axdata))) - axvec = "tight"; - return; - endif - - ## compute axis limits - minv = axdata(1); - maxv = axdata(2); - delv = (maxv-minv)/2; # breadth of the plot - midv = (minv + maxv)/2; # midpoint of the plot - axmid = [midv, midv]; - axdel = [-0.1, 0.1]; # default plot width (if less than 2-d data) - - if (delv == 0) - if (midv != 0) - axdel = [-0.1*midv, 0.1*midv]; - endif - else - ## they're at least one-dimensional - tolv = max(1e-8, 1e-8*abs(midv)); - if (abs (delv) >= tolv) - axdel = 1.1*[-delv,delv]; - endif - endif - - axvec = axmid + axdel; - -endfunction Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2011-12-11 16:49:39 UTC (rev 9366) +++ trunk/octave-forge/main/control/inst/bode.m 2011-12-11 19:05:54 UTC (rev 9367) @@ -72,16 +72,14 @@ subplot (2, 1, 1) semilogx (w, mag_db) - axis ("tight") - %ylim (__plot_margin__ (ylim)); + axis (__axis_margin__ (axis, w(1), w(end))) grid ("on") title (["Bode Diagram of ", inputname(1)]) ylabel ("Magnitude [dB]") subplot (2, 1, 2) semilogx (w, pha) - axis ("tight") - %ylim (__plot_margin__ (ylim)); + axis (__axis_margin__ (axis, w(1), w(end))) grid ("on") xlabel (xl_str) ylabel ("Phase [deg]") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2011-12-11 19:46:12
|
Revision: 9368 http://octave.svn.sourceforge.net/octave/?rev=9368&view=rev Author: paramaniac Date: 2011-12-11 19:46:06 +0000 (Sun, 11 Dec 2011) Log Message: ----------- control: axis problem still not fixed Modified Paths: -------------- trunk/octave-forge/main/control/inst/__axis_margin__.m trunk/octave-forge/main/control/inst/bode.m Modified: trunk/octave-forge/main/control/inst/__axis_margin__.m =================================================================== --- trunk/octave-forge/main/control/inst/__axis_margin__.m 2011-12-11 19:05:54 UTC (rev 9367) +++ trunk/octave-forge/main/control/inst/__axis_margin__.m 2011-12-11 19:46:06 UTC (rev 9368) @@ -36,11 +36,11 @@ ## @end table ## @end deftypefn -function axvec = __axis_margin__ (axdata, left, right) +function axvec = __axis_margin__ (axdata) ## compute axis limits - minv = axdata(3); - maxv = axdata(4); + minv = axdata(1); + maxv = axdata(2); delv = (maxv-minv)/2; # breadth of the plot midv = (minv + maxv)/2; # midpoint of the plot axmid = [midv, midv]; @@ -58,6 +58,6 @@ endif endif - axvec = [left, right, axmid + axdel]; + axvec = axmid + axdel; endfunction Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2011-12-11 19:05:54 UTC (rev 9367) +++ trunk/octave-forge/main/control/inst/bode.m 2011-12-11 19:46:06 UTC (rev 9368) @@ -72,14 +72,16 @@ subplot (2, 1, 1) semilogx (w, mag_db) - axis (__axis_margin__ (axis, w(1), w(end))) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") title (["Bode Diagram of ", inputname(1)]) ylabel ("Magnitude [dB]") subplot (2, 1, 2) semilogx (w, pha) - axis (__axis_margin__ (axis, w(1), w(end))) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") xlabel (xl_str) ylabel ("Phase [deg]") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-01-18 14:41:27
|
Revision: 9532 http://octave.svn.sourceforge.net/octave/?rev=9532&view=rev Author: paramaniac Date: 2012-01-18 14:41:16 +0000 (Wed, 18 Jan 2012) Log Message: ----------- control: support frequency response in the range {wmin, wmax}, e.g. bode (sys, {wmin, wmax}) Modified Paths: -------------- trunk/octave-forge/main/control/inst/__frequency_response__.m trunk/octave-forge/main/control/inst/__frequency_vector__.m Modified: trunk/octave-forge/main/control/inst/__frequency_response__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_response__.m 2012-01-18 14:02:54 UTC (rev 9531) +++ trunk/octave-forge/main/control/inst/__frequency_response__.m 2012-01-18 14:41:16 UTC (rev 9532) @@ -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. ## @@ -21,7 +21,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.3 function [H, w] = __frequency_response__ (sys, w = [], mimoflag = 0, resptype = 0, wbounds = "std", cellflag = false) @@ -42,6 +42,8 @@ endif elseif (isempty (w)) # find interesting frequency range w if not specified w = __frequency_vector__ (sys, wbounds); + elseif (iscell (w) && numel (w) == 2 && issample (w{1}) && issample (w{2})) + w = __frequency_vector__ (sys, wbounds, w{1}, w{2}); elseif (! is_real_vector (w)) error ("frequency_response: second argument w must be a vector of frequencies"); endif Modified: trunk/octave-forge/main/control/inst/__frequency_vector__.m =================================================================== --- trunk/octave-forge/main/control/inst/__frequency_vector__.m 2012-01-18 14:02:54 UTC (rev 9531) +++ trunk/octave-forge/main/control/inst/__frequency_vector__.m 2012-01-18 14:41:16 UTC (rev 9532) @@ -35,9 +35,9 @@ ## Adapted-By: Lukas Reichlin <luk...@gm...> ## Date: October 2009 -## Version: 0.2 +## Version: 0.3 -function w = __frequency_vector__ (sys, wbounds = "std") +function w = __frequency_vector__ (sys, wbounds = "std", wmin, wmax) zer = zero (sys); pol = pole (sys); @@ -119,6 +119,11 @@ dec_max = log10 (pi/tsam); endif + if (nargin == 4) # w = {wmin, wmax} + dec_min = log10 (wmin); + dec_max = log10 (wmax); + endif + ## create frequency vector zp = [abs(zer), abs(pol)]; idx = find (zp > 10^dec_min & zp < 10^dec_max); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-02-09 13:42:51
|
Revision: 9599 http://octave.svn.sourceforge.net/octave/?rev=9599&view=rev Author: paramaniac Date: 2012-02-09 13:42:44 +0000 (Thu, 09 Feb 2012) Log Message: ----------- control: document new feature of frequency response commands 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/sigma.m Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2012-02-08 21:46:43 UTC (rev 9598) +++ trunk/octave-forge/main/control/inst/bode.m 2012-02-09 13:42:44 UTC (rev 9599) @@ -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. ## @@ -28,6 +28,9 @@ ## @item w ## Optional vector of frequency values. If @var{w} is not specified, ## it is calculated by the zeros and poles of the system. +## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range, +## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies +## in rad/s. ## @end table ## ## @strong{Outputs} Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2012-02-08 21:46:43 UTC (rev 9598) +++ trunk/octave-forge/main/control/inst/bodemag.m 2012-02-09 13:42:44 UTC (rev 9599) @@ -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. ## @@ -28,6 +28,9 @@ ## @item w ## Optional vector of frequency values. If @var{w} is not specified, ## it is calculated by the zeros and poles of the system. +## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range, +## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies +## in rad/s. ## @end table ## ## @strong{Outputs} Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2012-02-08 21:46:43 UTC (rev 9598) +++ trunk/octave-forge/main/control/inst/nichols.m 2012-02-09 13:42:44 UTC (rev 9599) @@ -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. ## @@ -28,6 +28,9 @@ ## @item w ## Optional vector of frequency values. If @var{w} is not specified, ## it is calculated by the zeros and poles of the system. +## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range, +## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies +## in rad/s. ## @end table ## ## @strong{Outputs} Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2012-02-08 21:46:43 UTC (rev 9598) +++ trunk/octave-forge/main/control/inst/nyquist.m 2012-02-09 13:42:44 UTC (rev 9599) @@ -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. ## @@ -28,6 +28,9 @@ ## @item w ## Optional vector of frequency values. If @var{w} is not specified, ## it is calculated by the zeros and poles of the system. +## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range, +## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies +## in rad/s. ## @end table ## ## @strong{Outputs} Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2012-02-08 21:46:43 UTC (rev 9598) +++ trunk/octave-forge/main/control/inst/sigma.m 2012-02-09 13:42:44 UTC (rev 9599) @@ -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. ## @@ -30,6 +30,9 @@ ## @item w ## Optional vector of frequency values. If @var{w} is not specified, ## it is calculated by the zeros and poles of the system. +## Alternatively, the cell @code{@{wmin, wmax@}} specifies a frequency range, +## where @var{wmin} and @var{wmax} denote minimum and maximum frequencies +## in rad/s. ## @item ptype = 0 ## Singular values of the frequency response @var{H} of system @var{sys}. Default Value. ## @item ptype = 1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-02-09 17:41:22
|
Revision: 9602 http://octave.svn.sourceforge.net/octave/?rev=9602&view=rev Author: paramaniac Date: 2012-02-09 17:41:11 +0000 (Thu, 09 Feb 2012) Log Message: ----------- control: replace num2cell + cellfun by arrayfun (arrayfun became an oct-file in octave 3.6.0) Modified Paths: -------------- trunk/octave-forge/main/control/inst/@frd/__sys_group__.m trunk/octave-forge/main/control/inst/@frd/display.m trunk/octave-forge/main/control/inst/@ss/__freqresp__.m trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m trunk/octave-forge/main/control/inst/ctrb.m trunk/octave-forge/main/control/inst/strseq.m Modified: trunk/octave-forge/main/control/inst/@frd/__sys_group__.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/__sys_group__.m 2012-02-09 14:14:36 UTC (rev 9601) +++ trunk/octave-forge/main/control/inst/@frd/__sys_group__.m 2012-02-09 17:41:11 UTC (rev 9602) @@ -1,4 +1,4 @@ -## Copyright (C) 2010 Lukas F. Reichlin +## Copyright (C) 2010, 2012 Lukas F. Reichlin ## ## This file is part of LTI Syncope. ## @@ -22,7 +22,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2010 -## Version: 0.1 +## Version: 0.2 function retsys = __sys_group__ (sys1, sys2) @@ -53,11 +53,10 @@ else # differing frequency vectors ## find common frequencies retsys.w = w = intersect (sys1.w, sys2.w); - w = num2cell (w); ## indices of common frequencies - w1_idx = cellfun (@(x) find (sys1.w == x), w); - w2_idx = cellfun (@(x) find (sys2.w == x), w); + w1_idx = arrayfun (@(x) find (sys1.w == x), w); + w2_idx = arrayfun (@(x) find (sys2.w == x), w); ## extract common responses H1 = sys1.H(:, :, w1_idx); Modified: trunk/octave-forge/main/control/inst/@frd/display.m =================================================================== --- trunk/octave-forge/main/control/inst/@frd/display.m 2012-02-09 14:14:36 UTC (rev 9601) +++ trunk/octave-forge/main/control/inst/@frd/display.m 2012-02-09 17:41:11 UTC (rev 9602) @@ -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. ## @@ -20,7 +20,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: February 2010 -## Version: 0.1 +## Version: 0.2 function display (sys) @@ -123,13 +123,12 @@ vec = vec(:); tmp = isfinite (vec); tmp = abs (vec(tmp & vec != 0)); - vec = num2cell (vec); if (isempty (tmp) || min (tmp) < 1e-3 || max (tmp) > 1e4) - str = cellfun (@(x) sprintf ("%.3e", x), vec, "uniformoutput", false); + str = arrayfun (@(x) sprintf ("%.3e", x), vec, "uniformoutput", false); elseif (all (floor (tmp) == tmp)) - str = cellfun (@(x) sprintf ("%d", x), vec, "uniformoutput", false); + str = arrayfun (@(x) sprintf ("%d", x), vec, "uniformoutput", false); else - str = cellfun (@(x) sprintf ("%.4f", x), vec, "uniformoutput", false); + str = arrayfun (@(x) sprintf ("%.4f", x), vec, "uniformoutput", false); endif str = strjust (char (str), "right"); if (nargin > 1) Modified: trunk/octave-forge/main/control/inst/@ss/__freqresp__.m =================================================================== --- trunk/octave-forge/main/control/inst/@ss/__freqresp__.m 2012-02-09 14:14:36 UTC (rev 9601) +++ trunk/octave-forge/main/control/inst/@ss/__freqresp__.m 2012-02-09 17:41:11 UTC (rev 9602) @@ -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: October 2009 -## Version: 0.4 +## Version: 0.5 function H = __freqresp__ (sys, w, resptype = 0, cellflag = false) @@ -35,25 +35,25 @@ endif if (isct (sys)) # continuous system - s = num2cell (i * w); + s = i * w; else # discrete system - s = num2cell (exp (i * w * abs (tsam))); + s = exp (i * w * abs (tsam)); endif switch (resptype) case 0 # default system - H = cellfun (@(x) c/(x*e - a)*b + d, s, "uniformoutput", false); + H = arrayfun (@(x) c/(x*e - a)*b + d, s, "uniformoutput", false); case 1 # inversed system - H = cellfun (@(x) inv (c/(x*e - a)*b + d), s, "uniformoutput", false); + H = arrayfun (@(x) inv (c/(x*e - a)*b + d), s, "uniformoutput", false); case 2 # inversed sensitivity j = eye (columns (b)); - H = cellfun (@(x) j + c/(x*e - a)*b + d, s, "uniformoutput", false); + H = arrayfun (@(x) j + c/(x*e - a)*b + d, s, "uniformoutput", false); case 3 # inversed complementary sensitivity j = eye (columns (b)); - H = cellfun (@(x) j + inv (c/(x*e - a)*b + d), s, "uniformoutput", false); + H = arrayfun (@(x) j + inv (c/(x*e - a)*b + d), s, "uniformoutput", false); otherwise error ("ss: freqresp: invalid response type"); Modified: trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m =================================================================== --- trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m 2012-02-09 14:14:36 UTC (rev 9601) +++ trunk/octave-forge/main/control/inst/@tf/__sys2ss__.m 2012-02-09 17:41:11 UTC (rev 9602) @@ -128,8 +128,8 @@ max_len_numq = max (len_numq(:)); numq = cellfun (@(x) prepad (x, max_len_numq, 0, 2), numq, "uniformoutput", false); f = @(y) cellfun (@(x) x(y), numq); - s = num2cell (1 : max_len_numq); - D = cellfun (f, s, "uniformoutput", false); + s = 1 : max_len_numq; + D = arrayfun (f, s, "uniformoutput", false); e2 = diag (ones (p*(max_len_numq-1), 1), -p); a2 = eye (p*max_len_numq); Modified: trunk/octave-forge/main/control/inst/ctrb.m =================================================================== --- trunk/octave-forge/main/control/inst/ctrb.m 2012-02-09 14:14:36 UTC (rev 9601) +++ trunk/octave-forge/main/control/inst/ctrb.m 2012-02-09 17:41:11 UTC (rev 9602) @@ -1,4 +1,4 @@ -## Copyright (C) 2009, 2010 Lukas F. Reichlin +## Copyright (C) 2009, 2010, 2012 Lukas F. Reichlin ## Copyright (C) 2009 Luca Favatella <sla...@gm...> ## ## This file is part of LTI Syncope. @@ -53,7 +53,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: October 2009 -## Version: 0.2 +## Version: 0.3 function co = ctrb (a, b) @@ -71,9 +71,9 @@ endif n = rows (a); # number of states - k = num2cell (0:n-1); # exponents for a + k = 0:n-1; # exponents for a - tmp = cellfun (@(x) a^x*b, k, "uniformoutput", false); + tmp = arrayfun (@(x) a^x*b, k, "uniformoutput", false); co = horzcat (tmp{:}); Modified: trunk/octave-forge/main/control/inst/strseq.m =================================================================== --- trunk/octave-forge/main/control/inst/strseq.m 2012-02-09 14:14:36 UTC (rev 9601) +++ trunk/octave-forge/main/control/inst/strseq.m 2012-02-09 17:41:11 UTC (rev 9602) @@ -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. ## @@ -28,7 +28,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: September 2009 -## Version: 0.2 +## Version: 0.3 function strvec = strseq (str, idx) @@ -36,8 +36,6 @@ print_usage (); endif - idx = reshape (num2cell (idx), [], 1); + strvec = arrayfun (@(x) sprintf ("%s%d", str, x), idx(:), "uniformoutput", false); - strvec = cellfun (@(x) sprintf ("%s%d", str, x), idx, "uniformoutput", false); - endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-02-09 18:12:31
|
Revision: 9604 http://octave.svn.sourceforge.net/octave/?rev=9604&view=rev Author: paramaniac Date: 2012-02-09 18:12:24 +0000 (Thu, 09 Feb 2012) Log Message: ----------- control: simplify frequency response commands (all except margin which is still missing) 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/sigma.m Modified: trunk/octave-forge/main/control/inst/bode.m =================================================================== --- trunk/octave-forge/main/control/inst/bode.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/bode.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.3 +## Version: 0.4 function [mag_r, pha_r, w_r] = bode (sys, w = []) @@ -67,12 +67,6 @@ if (! nargout) mag_db = 20 * log10 (mag); - wv = [min(w), max(w)]; - ax_vec_mag = __axis_limits__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); - ax_vec_mag(1:2) = wv; - ax_vec_pha = __axis_limits__ ([reshape(w, [], 1), reshape(pha, [], 1)]); - ax_vec_pha(1:2) = wv; - if (isct (sys)) xl_str = "Frequency [rad/s]"; else @@ -81,18 +75,16 @@ subplot (2, 1, 1) semilogx (w, mag_db) - ax = axis; - if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros - ax_vec_mag(3:4) = ax(3:4); - endif - axis (ax_vec_mag) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") title (["Bode Diagram of ", inputname(1)]) ylabel ("Magnitude [dB]") subplot (2, 1, 2) semilogx (w, pha) - axis (ax_vec_pha) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") xlabel (xl_str) ylabel ("Phase [deg]") Modified: trunk/octave-forge/main/control/inst/bodemag.m =================================================================== --- trunk/octave-forge/main/control/inst/bodemag.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/bodemag.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -46,7 +46,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.3 +## Version: 0.4 function [mag_r, w_r] = bodemag (sys, w = []) @@ -64,10 +64,6 @@ if (! nargout) mag_db = 20 * log10 (mag); - wv = [min(w), max(w)]; - ax_vec_mag = __axis_limits__ ([reshape(w, [], 1), reshape(mag_db, [], 1)]); - ax_vec_mag(1:2) = wv; - if (isct (sys)) xl_str = "Frequency [rad/s]"; else @@ -75,11 +71,8 @@ endif semilogx (w, mag_db) - ax = axis; - if (any (isinf (ax_vec_mag))) # catch case purely imaginary poles or zeros - ax_vec_mag(3:4) = ax(3:4); - endif - axis (ax_vec_mag) + axis ("tight") + ylim (__axis_margin__ (ylim)) grid ("on") title (["Bode Magnitude Diagram of ", inputname(1)]) xlabel (xl_str) Modified: trunk/octave-forge/main/control/inst/nichols.m =================================================================== --- trunk/octave-forge/main/control/inst/nichols.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/nichols.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.3 +## Version: 0.4 function [mag_r, pha_r, w_r] = nichols (sys, w = []) @@ -66,14 +66,11 @@ if (! nargout) mag_db = 20 * log10 (mag); - ax_vec = __axis_limits__ ([reshape(pha, [], 1), reshape(mag_db, [], 1)]); plot (pha, mag_db) - ax = axis; - if (any (isinf (ax_vec))) # catch case purely imaginary poles or zeros - ax_vec(3:4) = ax(3:4); - endif - axis (ax_vec) + axis ("tight") + xlim (__axis_margin__ (xlim)) + ylim (__axis_margin__ (ylim)) grid ("on") title (["Nichols Chart of ", inputname(1)]) xlabel ("Phase [deg]") Modified: trunk/octave-forge/main/control/inst/nyquist.m =================================================================== --- trunk/octave-forge/main/control/inst/nyquist.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/nyquist.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -48,7 +48,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: November 2009 -## Version: 0.2 +## Version: 0.3 function [re_r, im_r, w_r] = nyquist (sys, w = []) @@ -65,10 +65,10 @@ im = imag (H); if (! nargout) - ax_vec = __axis_limits__ ([re, im; re, -im]); - plot (re, im, "b", re, -im, "r") - axis (ax_vec) + axis ("tight") + xlim (__axis_margin__ (xlim)) + ylim (__axis_margin__ (ylim)) grid ("on") title (["Nyquist Diagram of ", inputname(1)]) xlabel ("Real Axis") Modified: trunk/octave-forge/main/control/inst/sigma.m =================================================================== --- trunk/octave-forge/main/control/inst/sigma.m 2012-02-09 17:47:18 UTC (rev 9603) +++ trunk/octave-forge/main/control/inst/sigma.m 2012-02-09 18:12:24 UTC (rev 9604) @@ -60,7 +60,7 @@ ## Author: Lukas Reichlin <luk...@gm...> ## Created: May 2009 -## Version: 0.5 +## Version: 0.6 function [sv_r, w_r] = sigma (sys, w = [], resptype = 0) @@ -80,11 +80,6 @@ ## convert to dB for plotting sv_db = 20 * log10 (sv); - ## determine axes - ax_vec = __axis_limits__ ([reshape(w, [], 1), reshape(min(sv_db, [], 1), [], 1); - reshape(w, [], 1), reshape(max(sv_db, [], 1), [], 1)]); - ax_vec(1:2) = [min(w), max(w)]; - ## determine xlabel if (isct (sys)) xl_str = "Frequency [rad/s]"; @@ -94,15 +89,12 @@ ## plot results semilogx (w, sv_db, "b") - ax = axis; - if (any (isinf (ax_vec))) # catch case purely imaginary poles or zeros - ax_vec(3:4) = ax(3:4); - endif - axis (ax_vec) + axis ("tight") + ylim (__axis_margin__ (ylim)) + grid ("on") title (["Singular Values of ", inputname(1)]) xlabel (xl_str) ylabel ("Singular Values [dB]") - grid ("on") else # return values sv_r = sv; w_r = reshape (w, [], 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <par...@us...> - 2012-02-25 20:06:08
|
Revision: 9680 http://octave.svn.sourceforge.net/octave/?rev=9680&view=rev Author: paramaniac Date: 2012-02-25 20:06:02 +0000 (Sat, 25 Feb 2012) Log Message: ----------- control: tinker with example Modified Paths: -------------- trunk/octave-forge/main/control/inst/optiPID.m trunk/octave-forge/main/control/inst/optiPIDfun.m Added Paths: ----------- trunk/octave-forge/main/control/inst/optiPIDctrl.m Modified: trunk/octave-forge/main/control/inst/optiPID.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPID.m 2012-02-25 15:59:51 UTC (rev 9679) +++ trunk/octave-forge/main/control/inst/optiPID.m 2012-02-25 20:06:02 UTC (rev 9680) @@ -48,9 +48,7 @@ Td_AH = Tu * 0.15 * exp ( -1.40 * kappa + 0.56 * kappa^2 ) tau_AH = Td_AH / 10 -numC_AH = kp_AH * [Ti_AH * Td_AH, Ti_AH, 1]; -denC_AH = conv ([Ti_AH, 0], [tau_AH^2, 2 * tau_AH, 1]); -C_AH = tf (numC_AH, denC_AH); +C_AH = optiPIDctrl (kp_AH, Ti_AH, Td_AH, tau_AH); % Initial Values C_par_0 = [kp_AH; Ti_AH; Td_AH]; @@ -71,9 +69,7 @@ Td_opt = C_par_opt(3) tau_opt = Td_opt / 10 -numC_opt = kp_opt * [Ti_opt * Td_opt, Ti_opt, 1]; -denC_opt = conv ([Ti_opt, 0], [tau_opt^2, 2 * tau_opt, 1]); -C_opt = tf (numC_opt, denC_opt); +C_opt = optiPIDctrl (kp_opt, Ti_opt, Td_opt, tau_opt); % Open Loop L_AH = P * C_AH; Added: trunk/octave-forge/main/control/inst/optiPIDctrl.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPIDctrl.m (rev 0) +++ trunk/octave-forge/main/control/inst/optiPIDctrl.m 2012-02-25 20:06:02 UTC (rev 9680) @@ -0,0 +1,8 @@ +function C = optiPIDctrl (Kp, Ti, Td, tau) + + 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 Modified: trunk/octave-forge/main/control/inst/optiPIDfun.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPIDfun.m 2012-02-25 15:59:51 UTC (rev 9679) +++ trunk/octave-forge/main/control/inst/optiPIDfun.m 2012-02-25 20:06:02 UTC (rev 9680) @@ -18,9 +18,7 @@ tau = Td / 10; % PID Controller with Roll-Off - numC = kp * [Ti*Td, Ti, 1]; - denC = conv ([Ti, 0], [tau^2, 2*tau, 1]); - C = tf (numC, denC); + C = optiPIDctrl (kp, Ti, Td, tau); % 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-02-25 20:14:58
|
Revision: 9681 http://octave.svn.sourceforge.net/octave/?rev=9681&view=rev Author: paramaniac Date: 2012-02-25 20:14:52 +0000 (Sat, 25 Feb 2012) Log Message: ----------- control: tinker with example (2) 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-25 20:06:02 UTC (rev 9680) +++ trunk/octave-forge/main/control/inst/optiPID.m 2012-02-25 20:14:52 UTC (rev 9681) @@ -46,9 +46,8 @@ kp_AH = ku * 0.72 * exp ( -1.60 * kappa + 1.20 * kappa^2 ) Ti_AH = Tu * 0.59 * exp ( -1.30 * kappa + 0.38 * kappa^2 ) Td_AH = Tu * 0.15 * exp ( -1.40 * kappa + 0.56 * kappa^2 ) -tau_AH = Td_AH / 10 -C_AH = optiPIDctrl (kp_AH, Ti_AH, Td_AH, tau_AH); +C_AH = optiPIDctrl (kp_AH, Ti_AH, Td_AH); % Initial Values C_par_0 = [kp_AH; Ti_AH; Td_AH]; @@ -69,7 +68,7 @@ Td_opt = C_par_opt(3) tau_opt = Td_opt / 10 -C_opt = optiPIDctrl (kp_opt, Ti_opt, Td_opt, tau_opt); +C_opt = optiPIDctrl (kp_opt, Ti_opt, Td_opt); % Open Loop L_AH = P * C_AH; Modified: trunk/octave-forge/main/control/inst/optiPIDctrl.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPIDctrl.m 2012-02-25 20:06:02 UTC (rev 9680) +++ trunk/octave-forge/main/control/inst/optiPIDctrl.m 2012-02-25 20:14:52 UTC (rev 9681) @@ -1,5 +1,7 @@ -function C = optiPIDctrl (Kp, Ti, Td, tau) +function C = optiPIDctrl (Kp, Ti, Td) + tau = Td / 10; + num = Kp * [Ti*Td, Ti, 1]; den = conv ([Ti, 0], [tau^2, 2*tau, 1]); Modified: trunk/octave-forge/main/control/inst/optiPIDfun.m =================================================================== --- trunk/octave-forge/main/control/inst/optiPIDfun.m 2012-02-25 20:06:02 UTC (rev 9680) +++ trunk/octave-forge/main/control/inst/optiPIDfun.m 2012-02-25 20:14:52 UTC (rev 9681) @@ -11,15 +11,9 @@ % Global Variables global P t dt mu_1 mu_2 mu_3 - % Function Argument -> Controller Parameters - kp = C_par(1); - Ti = C_par(2); - Td = C_par(3); - tau = Td / 10; + % Function Argument -> PID Controller with Roll-Off + C = optiPIDctrl (num2cell (C_par){:}); - % PID Controller with Roll-Off - C = optiPIDctrl (kp, Ti, Td, tau); - % 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-02-28 07:40:03
|
Revision: 9715 http://octave.svn.sourceforge.net/octave/?rev=9715&view=rev Author: paramaniac Date: 2012-02-28 07:39:52 +0000 (Tue, 28 Feb 2012) Log Message: ----------- control: describe and return argument rcond Modified Paths: -------------- trunk/octave-forge/main/control/inst/h2syn.m trunk/octave-forge/main/control/inst/hinfsyn.m trunk/octave-forge/main/control/inst/mixsyn.m Modified: trunk/octave-forge/main/control/inst/h2syn.m =================================================================== --- trunk/octave-forge/main/control/inst/h2syn.m 2012-02-28 06:58:23 UTC (rev 9714) +++ trunk/octave-forge/main/control/inst/h2syn.m 2012-02-28 07:39:52 UTC (rev 9715) @@ -41,6 +41,13 @@ ## State-space model of the lower LFT of @var{P} and @var{K}. ## @item gamma ## H-2 norm of @var{N}. +## @item rcond +## Vector @var{rcond} contains estimates of the reciprocal condition +## numbers of the matrices which are to be inverted and +## estimates of the reciprocal condition numbers of the +## Riccati equations which have to be solved during the +## computation of the controller @var{K}. For details, +## see the description of the corresponding SLICOT algorithm. ## @end table ## ## @strong{Block Diagram} Modified: trunk/octave-forge/main/control/inst/hinfsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/hinfsyn.m 2012-02-28 06:58:23 UTC (rev 9714) +++ trunk/octave-forge/main/control/inst/hinfsyn.m 2012-02-28 07:39:52 UTC (rev 9715) @@ -45,6 +45,13 @@ ## State-space model of the lower LFT of @var{P} and @var{K}. ## @item gamma ## L-infinity norm of @var{N}. +## @item rcond +## Vector @var{rcond} contains estimates of the reciprocal condition +## numbers of the matrices which are to be inverted and +## estimates of the reciprocal condition numbers of the +## Riccati equations which have to be solved during the +## computation of the controller @var{K}. For details, +## see the description of the corresponding SLICOT algorithm. ## @end table ## ## @strong{Block Diagram} Modified: trunk/octave-forge/main/control/inst/mixsyn.m =================================================================== --- trunk/octave-forge/main/control/inst/mixsyn.m 2012-02-28 06:58:23 UTC (rev 9714) +++ trunk/octave-forge/main/control/inst/mixsyn.m 2012-02-28 07:39:52 UTC (rev 9715) @@ -16,7 +16,7 @@ ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}] =} mixsyn (@var{G}, @var{W1}, @var{W2}, @var{W3}, @dots{}) +## @deftypefn{Function File} {[@var{K}, @var{N}, @var{gamma}, @var{rcond}] =} mixsyn (@var{G}, @var{W1}, @var{W2}, @var{W3}, @dots{}) ## Solve stacked S/KS/T H-infinity problem. Bound the largest singular values ## of @var{S} (for performance), @var{K S} (to penalize large inputs) and ## @var{T} (for robustness and to avoid sensitivity to noise). @@ -52,6 +52,13 @@ ## State-space model of the lower LFT of @var{P} and @var{K}. ## @item gamma ## L-infinity norm of @var{N}. +## @item rcond +## Vector @var{rcond} contains estimates of the reciprocal condition +## numbers of the matrices which are to be inverted and +## estimates of the reciprocal condition numbers of the +## Riccati equations which have to be solved during the +## computation of the controller @var{K}. For details, +## see the description of the corresponding SLICOT algorithm. ## @end table ## ## @strong{Block Diagram} @@ -127,6 +134,12 @@ ## 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.} +## ## @seealso{hinfsyn, augw} ## @end deftypefn @@ -134,7 +147,7 @@ ## Created: December 2009 ## Version: 0.1 -function [K, N, gamma] = mixsyn (G, W1 = [], W2 = [], W3 = [], varargin) +function [K, N, gamma, rcond] = mixsyn (G, W1 = [], W2 = [], W3 = [], varargin) if (nargin == 0) print_usage (); @@ -144,6 +157,6 @@ P = augw (G, W1, W2, W3); - [K, N, gamma] = hinfsyn (P, p, m, varargin{:}); + [K, N, gamma, rcond] = hinfsyn (P, p, m, varargin{:}); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |