@c Copyright (C) 1996, 1997, 2007 John W. Eaton
@c
@c This file is part of Octave.
@c
@c Octave is free software; you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by the
@c Free Software Foundation; either version 3 of the License, or (at
@c your option) any later version.
@c 
@c Octave is distributed in the hope that it will be useful, but WITHOUT
@c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@c FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
@c for more details.
@c 
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING.  If not, see
@c <http://www.gnu.org/licenses/>.

@node Control Theory
@chapter Control Theory

The Octave Control Systems Toolbox (@acronym{OCST}) was initially developed
by Dr.@: A. Scottedward Hodel 
@email{a.s.hodel@@eng.auburn.edu} with the assistance
of his students
@itemize @bullet
@item R. Bruce Tenison @email{btenison@@dibbs.net}, 
@item David C. Clem,
@item John E. Ingram @email{John.Ingram@@sea.siemans.com}, and 
@item Kristi McGowan.  
@end itemize
This development was supported in part by @acronym{NASA}'s Marshall Space Flight 
Center as part of an in-house @acronym{CACSD} environment.  Additional important 
contributions were made by Dr. Kai Mueller @email{mueller@@ifr.ing.tu-bs.de}
and Jose Daniel Munoz Frias (@code{place.m}).

An on-line menu-driven tutorial is available via @code{DEMOcontrol};
beginning @acronym{OCST} users should start with this program. 

@DOCSTRING(DEMOcontrol)

@menu
* sysstruct::                   
* sysinterface::                
* sysdisp::                     
* blockdiag::                   
* numerical::                   
* sysprop::                     
* systime::                     
* sysfreq::                     
* cacsd::                       
* misc::                        
@end menu

@node sysstruct
@section System Data Structure

@menu
* sysstructvars::               
* sysstructtf::                 
* sysstructzp::                 
* sysstructss::                 
@end menu

The @acronym{OCST} stores all dynamic systems in
a single data structure format that can represent continuous systems,
discrete-systems, and mixed (hybrid) systems in state-space form, and
can also represent purely continuous/discrete systems in either
transfer function or pole-zero form. In order to
provide more flexibility in treatment of discrete/hybrid systems, the
@acronym{OCST} also keeps a record of which system outputs are sampled.

Octave structures are accessed with a syntax much like that used
by the C programming language.  For consistency in
use of the data structure used in the @acronym{OCST}, it is recommended that
the system structure access m-files be used (@pxref{sysinterface}).
Some elements of the data structure are absent depending on the internal
system representation(s) used.  More than one system representation
can be used for @acronym{SISO} systems; the @acronym{OCST} m-files ensure that all representations
used are consistent with one another.

@DOCSTRING(sysrepdemo)

@node sysstructvars
@subsection Variables common to all @acronym{OCST} system formats

The data structure elements (and variable types) common to all  system
representations are listed below; examples of the initialization
and use of the system data structures are given in subsequent sections and
in the online demo @code{DEMOcontrol}.
@table @var
@item n
@itemx nz
The respective number of continuous and discrete states
in the system (scalar)

@item inname
@itemx outname
list of name(s) of the system input, output signal(s). (list of strings)

@item sys
System status vector.  (vector)

This vector indicates both what representation was used to initialize
the system data structure (called the primary system type) and which
other representations are currently up-to-date with the primary system
type (@pxref{structaccess}).

The value of the first element of the vector indicates the primary
system type.

@table @asis
@item 0
for tf form (initialized with @code{tf2sys} or @code{fir2sys})

@item 1
for zp form (initialized with @code{zp2sys})

@item 2
for ss form (initialized with @code{ss2sys})
@end table

The next three elements are boolean flags that indicate whether tf, zp,
or ss, respectively, are ``up to date" (whether it is safe to use the
variables associated with these representations).  These flags are
changed when calls are made to the @code{sysupdate} command.

@item tsam
 Discrete time sampling period  (nonnegative scalar).
 @var{tsam} is set to 0 for continuous time systems.

@item yd
 Discrete-time output list (vector)

 indicates which outputs are discrete time (i.e.,
    produced by D/A converters) and which are continuous time.
    yd(ii) = 0 if output ii is continuous, = 1 if discrete.
@end table

The remaining variables of the  system data structure are only present
if the corresponding entry of the @code{sys} vector is true (=1).

@node sysstructtf
@subsection @code{tf} format variables

@table @var
@item num
 numerator coefficients   (vector)

@item den
 denominator coefficients   (vector)

@end table

@node sysstructzp
@subsection @code{zp} format variables

@table @var
@item zer
 system zeros   (vector)

@item pol
 system poles    (vector)

@item k
 leading coefficient   (scalar)

@end table

@node sysstructss
@subsection @code{ss} format variables

@table @var
@item a
@itemx b
@itemx c
@itemx d
The usual state-space matrices. If a system has both
        continuous and discrete states, they are sorted so that
        continuous states come first, then discrete states

@strong{Note} some functions (e.g., @code{bode}, @code{hinfsyn}) 
will not accept systems with both discrete and continuous states/outputs

@item stname
names of system states   (list of strings)

@end table

@node sysinterface
@section System Construction and Interface Functions

Construction and manipulations of the @acronym{OCST} system data structure
(@pxref{sysstruct}) requires attention to many details in order
to ensure that data structure contents remain consistent.  Users
are strongly encouraged to use the system interface functions
in this section.  Functions for the formatted display in of system
data structures are given in @ref{sysdisp}.

@menu
* fir2sys::                     
* ss2sys::                      
* tf2sys::                      
* zp2sys::                      
* structaccess::                
@end menu

@node fir2sys
@subsection Finite impulse response system interface functions

@DOCSTRING(fir2sys)

@DOCSTRING(sys2fir)

@node ss2sys
@subsection State space system interface functions

@DOCSTRING(ss)

@DOCSTRING(ss2sys)

@DOCSTRING(sys2ss)

@node tf2sys
@subsection Transfer function system interface functions

@DOCSTRING(tf)

@DOCSTRING(tf2sys)

@DOCSTRING(sys2tf)

@node zp2sys
@subsection Zero-pole system interface functions

@DOCSTRING(zp)

@DOCSTRING(zp2sys)

@DOCSTRING(sys2zp)

@node structaccess
@subsection Data structure access functions

@DOCSTRING(syschnames)

@DOCSTRING(syschtsam)

@DOCSTRING(sysdimensions)

@DOCSTRING(sysgetsignals)

@DOCSTRING(sysgettype)

@DOCSTRING(syssetsignals)

@DOCSTRING(sysupdate)

@DOCSTRING(minfo)

@DOCSTRING(sysgettsam)

@node sysdisp
@section System display functions

@DOCSTRING(sysout)

@DOCSTRING(tfout)

@DOCSTRING(zpout)

@node blockdiag
@section Block Diagram Manipulations

@xref{systime}.

Unless otherwise noted, all parameters (input,output) are
system data structures.

@DOCSTRING(bddemo)

@DOCSTRING(buildssic)

@DOCSTRING(jet707)

@DOCSTRING(ord2)

@DOCSTRING(sysadd)

@DOCSTRING(sysappend)

@DOCSTRING(sysconnect)

@DOCSTRING(syscont)

@DOCSTRING(sysdisc)

@DOCSTRING(sysdup) 

@DOCSTRING(sysgroup)

@DOCSTRING(sysmult)

@DOCSTRING(sysprune)

@DOCSTRING(sysreorder)

@DOCSTRING(sysscale)

@DOCSTRING(syssub)

@DOCSTRING(ugain)

@DOCSTRING(wgt1o)

@DOCSTRING(parallel)

@DOCSTRING(sysmin)

@node numerical
@section Numerical Functions

@DOCSTRING(are)

@DOCSTRING(dare)

@DOCSTRING(dre)

@DOCSTRING(dgram)

@DOCSTRING(dlyap)

@DOCSTRING(gram)

@DOCSTRING(lyap)

@DOCSTRING(qzval)

@DOCSTRING(zgfmul)

@DOCSTRING(zgfslv)

@DOCSTRING(zginit)

@DOCSTRING(zgreduce)

@DOCSTRING(zgrownorm)

@DOCSTRING(zgscal)

@DOCSTRING(zgsgiv)

@DOCSTRING(zgshsr)

@strong{References}
@table @strong
@item  ZGEP
 Hodel, @cite{Computation of Zeros with Balancing}, 1992, Linear Algebra
 and its Applications
@item @strong{Generalized CG}
 Golub and Van Loan, @cite{Matrix Computations, 2nd ed} 1989.
@end table

@node sysprop
@section System Analysis-Properties

@DOCSTRING(analdemo)

@DOCSTRING(abcddim)

@DOCSTRING(ctrb)

@DOCSTRING(h2norm)

@DOCSTRING(hinfnorm)

@DOCSTRING(obsv)

@DOCSTRING(pzmap)

@DOCSTRING(is_abcd)

@DOCSTRING(is_controllable)

@DOCSTRING(is_detectable)

@DOCSTRING(is_dgkf)

@DOCSTRING(is_digital)

@DOCSTRING(is_observable)

@DOCSTRING(is_sample)

@DOCSTRING(is_siso)

@DOCSTRING(is_stabilizable)

@DOCSTRING(is_signal_list)

@DOCSTRING(is_stable)

@node systime
@section System Analysis-Time Domain

@DOCSTRING(c2d)

@DOCSTRING(d2c)

@DOCSTRING(dmr2d)

@DOCSTRING(damp)

@DOCSTRING(dcgain)

@DOCSTRING(impulse)

@DOCSTRING(step)

@node sysfreq
@section System Analysis-Frequency Domain

@strong{Demonstration/tutorial script}
@DOCSTRING(frdemo)

@DOCSTRING(bode)

@DOCSTRING(bode_bounds)

@DOCSTRING(freqchkw)

@DOCSTRING(ltifr)

@DOCSTRING(nyquist)

@DOCSTRING(nichols)

@DOCSTRING(tzero)

@DOCSTRING(tzero2)

@node cacsd
@section Controller Design

@DOCSTRING(dgkfdemo)

@DOCSTRING(hinfdemo)

@DOCSTRING(dlqe)

@DOCSTRING(dlqr)

@DOCSTRING(dkalman)

@DOCSTRING(h2syn)

@DOCSTRING(hinf_ctr)

@DOCSTRING(hinfsyn)

@DOCSTRING(hinfsyn_chk)

@DOCSTRING(hinfsyn_ric)

@DOCSTRING(lqe)

@DOCSTRING(lqg)

@DOCSTRING(lqr)

@DOCSTRING(lsim)

@DOCSTRING(place)

@node misc
@section Miscellaneous Functions (Not yet properly filed/documented)

@DOCSTRING(axis2dlim)

@DOCSTRING(moddemo)

@DOCSTRING(prompt)

@DOCSTRING(rldemo)

@DOCSTRING(rlocus)

@DOCSTRING(sortcom)

@DOCSTRING(ss2tf)

@DOCSTRING(ss2zp)

@DOCSTRING(starp)

@DOCSTRING(tf2ss)

@DOCSTRING(tf2zp)

@DOCSTRING(zp2ss)

@DOCSTRING(zp2tf)

