PSS Common Module
MATLAB toolboxes for aerospace analysis
Common Functions

The Common module functions. View the published Common Demos. More...

Directories

directory Atmosphere
 Atmosphere models.
 
directory Classes
 Useful classes.
 
directory ComponentModels
 CAD component models.
 
directory Control
 Control functions.
 
directory ControlGUI
 Control GUI.
 
directory Database
 Database building functions.
 
directory DemoFuns
 Functions supporting demos.
 
directory Control
 Control scripts.
 
directory ControlGUI
 Control loop test.
 
directory Database
 Database demo.
 
directory General
 General demes.
 
directory GeneralEstimation
 Estimation demos.
 
directory Graphics
 Graphics demos.
 
directory Help
 FileHelp demo.
 
directory Plugins
 Plugin demos.
 
directory UKF
 Unscented Kalman filter demos.
 
directory Estimation
 Estimation including extended and unscented Kalman filters.
 
directory FileUtils
 File utilities.
 
directory GUIs
 Dialogs and GUIs including time displays.
 
directory General
 General purpose utilities.
 
directory Graphics
 Graphics utilities.
 
directory Interface
 Interfaces to other software.
 
directory MassProperties
 Mass properties functions.
 
directory Materials
 Materials properties utilities.
 
directory Plugins
 Graphical PlugIn functions for building GUIs.
 
directory Quaternion
 Quaternion utilities.
 
directory Reliability
 Reliability of series and parallel items.
 
directory Time
 Time utilities including Julian date.
 
directory Transform
 Common coordinate transforms.
 

Functions

function RFromCPAndGamma (in cP, in gamma)
 Computes R from cP and gamma. More...
 
function SimpAtm (in altitude, in units)
 Simplified atmosphere model. More...
 
function StdAtm (in altitude, in AtmData, in units)
 Computes atmospheric density based on the standard atmosphere model. More...
 
function AggregateComponents (in c, in scale)
 Aggregate CAD component vertices and faces. More...
 
function Box (in x, in y, in z, in openFace)
 Generate a box centered at the origin. More...
 
function BoxWithRoundedSection (in x, in y, in z)
 Generate a box with a rounded section. More...
 
function Cone (in p, in u, in halfAngle, in l, in n)
 Compute the vertices for a cone. More...
 
function CylinderWithHemisphere (in r, in h)
 Generates a cylinder with a hemisphere on one end instead of a flat disk. More...
 
function Disk (in r, in n, in z)
 Generate a disk. More...
 
function Extrude (in z, in c, in topClosed, in bottomClosed, in cI)
 Generate an object from cross sections. More...
 
function ExtrudeFromProfile (in z, in r, in topClosed, in bottomClosed, in n, in rI)
 Extrude from a radial profile. More...
 
function Frustrum (in rL, in r0, in l, in n, in topOpen, in bottomOpen, in angleStart, in angleEnd)
 Generate a frustrum of a cone. More...
 
function GeomPatch (in d, in cData, in cMap)
 Get vertices for surfaces of revolution, ellipsoids and cylinders. More...
 
function Icosahedron ()
 Generate an icosahedron inscribed in a unit sphere. More...
 
function MeshEllipsoid (in a, in b, in c, in n)
 Create a mesh ellipsoid. More...
 
function OpenFrame (in x, in y, in h, in t)
 Generate an open frame. More...
 
function ParabolicReflector (in d, in f, in m, in p)
 Generate a parabolic reflector. More...
 
function PartialDisk (in r, in t, in n, in angle)
 Generate vertices and faces for a full or partial disk. More...
 
function PlateTwoSided (in x, in y, in z)
 Generate a plate in the xy plane. More...
 
function Ring (in rO, in rI, in l, in w, in n)
 Generate a ring with specified inner and outer wall, and length. More...
 
function SectorPatch (in r0, in u1, in u2, in scale)
 Compute faces and vertices for a sector patch. More...
 
function ShapedStrut (in x1, in x2, in c)
 Generate strut going from x1 to x2. More...
 
function Strut (in x1, in x2, in r1, in r2, in n)
 Generate a variable radius strut going from x1 to x2. More...
 
function Torus (in c, in r, in n, in c2, in nuX)
 Draws a torus. More...
 
function Triangle (in x, in y, in z, in mass)
 Generate a solid triangle. More...
 
function TriangularTruss (in x1, in x2, in d, in n)
 Generate a triangular truss going from x1 to x2. More...
 
function Truss (in x1, in x2, in w, in n, in wBar)
 Generate a square truss going from x1 to x2. More...
 
function Tube (in rO, in rI, in l, in n)
 Generate a tube with specified inner and outer wall, and length. More...
 
function TubeArc (in rO, in rI, in l, in arc, in n)
 Generate a portion of a tube with an inner and outer wall. More...
 
function TubeSection (in rO, in rI, in l, in ang1, in ang2, in n)
 Generate a tube with specified inner and outer wall, and length. More...
 
function TubeWithBends (in r, in p, in nB, in nC)
 Generate a tube with bends. More...
 
function Tubing (in p, in d, in n)
 Generate a tube through the points p. More...
 
function UChannel (in x, in y, in z, in t, in d, in b)
 Generate a box with a u cut at the +x end. More...
 
function Wedge (in x1, in x2, in w, in t)
 Generate a wedge between x1 and x2. More...
 
function Acker (in a, in b, in p)
 Gains for poles using Ackermann's formula. More...
 
function ACTF (in e)
 Generic sensor or actuator model. More...
 
function Alias (in w, in ws)
 Computes the fundamental alias of a frequency. More...
 
function AllanVariance (in x, in t)
 Implements the overlapping Allan Variance. More...
 
function Append (in a1, in b1, in c1, in d1, in a2, in b2, in c2, in d2)
 Appends two state space systems. More...
 
function BalReal (in a, in b, in c, in d)
 Compute the balanced realization of a, b, c, d. More...
 
function BalRealG (in g)
 Computes a balanced realization of g. More...
 
function BodeGP (in g, in w)
 Computes the phase using the Bode gain phase rule. More...
 
function C2DelZOH (in a, in b, in T)
 Create a discrete time systems using the delta operator. More...
 
function C2DFOH (in a, in b, in T)
 Create a discrete time system using a first order hold. More...
 
function C2DPulse (in a, in b, in T, in tau)
 Create a discrete time system assuming a pulse at the input. More...
 
function C2DZOH (in a, in b, in T)
 Create a discrete time system using a zero order hold. More...
 
function C2DZOHWD (in a, in b, in c, in T, in Td)
 Create a discrete time system using a zero order hold and delay. More...
 
function CButter (in n, in wC, in tSamp, in sType)
 Create a continuous Butterworth Filter. More...
 
function CCVModel (in q)
 Generate CCV (control configured vehicle) aircraft model. More...
 
function CGram (in a, in b)
 Compute the controllability gramian for a continuous time system. More...
 
function CInputs (in t, in tStart, in d, in type)
 Generates different control inputs. More...
 
function CLoopS (in a, in b, in c, in ac, in bc, in cc, in dc)
 Creates a closed loop system. More...
 
function CLPoles (in a, in b, in c, in f, in g, in h, in k)
 Computes the closed loop poles. More...
 
function CompE (in x, in sType, in dT)
 Create a SISO compensator using a variety of compensator elements. More...
 
function CToD (in g, in dT, in sType)
 Create a discrete time compensator from a continuous time compensator. More...
 
function DBalReal (in a, in b, in c, in d)
 Compute a balanced realization for discrete time systems. More...
 
function DBode (in a, in b, in c, in d, in iy, in iu, in w, in dT)
 Generates a Bode plot for a discrete time system. More...
 
function DCGain (in a, in b, in c, in d, in sType)
 Computes the DC gain of a discrete time state space system. More...
 
function DCGram (in a, in b)
 Compute the controllability gramian for a discrete time system. More...
 
function Delay (in T, in n)
 Create a model of a delay using Pade approximants for exp(-sT). More...
 
function DigitalFilter (in uNew, in nN, in dN, in xN, in uN)
 Implement a digital filter. More...
 
function DispG (in action, in modifier)
 Display a statespace system using vertical bar charts. More...
 
function DOGram (in a, in c)
 Compute the observability gramian for a discrete time system. More...
 
function DQCE (in phi, in gamma, in h, in rw, in rv)
 Create an optimal estimator. More...
 
function DQCR (in a, in b, in q, in r, in n)
 Create a quadratic regulator. More...
 
function DRiccati (in g)
 Solves the discrete matrix Riccati equation. More...
 
function EigEval (in g, in hAxes)
 Evaluate the eigenvalues and eigenvectors graphically. More...
 
function ESAssign (in g, in lambda, in vD, in fC)
 Apply eigenvector and eigenvalue assignment. More...
 
function ESAssignDraper (in g, in lambda, in vD, in r, in fC)
 Apply eigenvector assignment using the Draper method. More...
 
function EVAssgnC (in g, in lambda, in vD, in d, in rD, in w)
 Use eigenvector assignment to design a controller. More...
 
function EVAssgnE (in g, in lambda, in vD, in d, in rD)
 Use eigevector assignment to design an estimator. More...
 
function EVDesMat (in nStates, in kAssign)
 Create the design matrix for the eigenstructure assignment technique. More...
 
function FFTEngy (in y, in tSamp, in aPeak, in noLog)
 Plot the energy in a signal. More...
 
function FindPeaks (in x, in y)
 Find peaks of the inputs by looking at slopes. More...
 
function FOPID (in e, in d)
 Fractional order PID controller. More...
 
function FResp (in a, in b, in c, in d, in iu, in iy, in w, in uPhase, in pType)
 Compute the frequency response of the system given a, b, c and d. More...
 
function FRespG (in f, in iu, in iy, in w, in uPhase, in pType)
 Compute the frequency response given the statespace class as input. More...
 
function FRespPlot (in mag, in phase, in w, in pType, in iu, in iy)
 Plot the frequency response of the system in Bode or Nichols form. More...
 
function Gen2nd (in zz, in wz, in zp, in wp, in tSamp, in sType)
 Creates a second order transfer function. More...
 
function GND (in num, in den, in w)
 Compute the frequency response given a numerator/denominator pair. More...
 
function GPMargin (in m, in p, in w)
 Computes gain and phase margins from magnitude and phase. More...
 
function GSS (in a, in b, in c, in d, in iu, in iy, in w)
 Compute the multivariable frequency response of the system. More...
 
function IC (in g, in x, in dT, in nSim)
 Generate a response to an initial condition vector. More...
 
function Integral (in Kdc, in w, in phase, in tSamp, in sType)
 Creates a general integrator. More...
 
function InvSys (in a, in b, in c, in d)
 Computes the inverse system. More...
 
function JLQOF (in k, in g, in w, in x)
 Linear quadratic regulator with an output feedback cost function. More...
 
function JLQTOF (in k, in g, in w, in t)
 Output feedback design with a reference input. More...
 
function JLQTWOF (in k, in g, in w, in t, in options)
 Output feedback design with a reference input. More...
 
function KronProd (in a, in b)
 Compute the Kronecker product. More...
 
function KronSum (in a, in b)
 Compute the Kronecker sum. More...
 
function KSmooth (in r, in phi, in q, in h, in z, in pI)
 Mechanizes a Kalman Filter fixed interval smoother. More...
 
function LeadLag (in wmax, in phasemax, in Kdc, in tSamp, in sType)
 Create a lead or lag. More...
 
function LFBal (in g, in gamma)
 Perform low frequency prebalancing of a system. More...
 
function Limit (in x, in limit)
 Limits a matrix. More...
 
function LQC (in g, in w, in type, in t)
 Design a quadratic controller. More...
 
function MagPlot (in a, in b, in c, in d, in iu, in iy, in w)
 Compute the magnitude frequency response of a system.s. More...
 
function MSR (in g, in q)
 Mean squared response of a system. More...
 
function ND2SS (in num, in den)
 Creates state-space model from numerator and denominator polynomials. More...
 
function NLFilter (in f, in h, in x, in t, in k, in u, in y, in dT)
 Implements a nonlinear fixed gain filter. More...
 
function Notch (in Kdb, in wc, in dw, in fType, in tSamp, in sType)
 Creates a second order transfer function. More...
 
function NQuant (in lSB, in rType)
 Computes the variance for various types of roundoff. More...
 
function NumericalTransferFunction (in f, in dT)
 Computes a numerical transfer function from the impulse response. More...
 
function Nyquist (in varargin)
 Generate a Nyquist plot from a statespace object or gain/phase data. More...
 
function OGram (in a, in c)
 Compute the observability gramian for a continuous time system. More...
 
function P3Axis (in qECIToBody, in d)
 A 3-axis proportional controller. More...
 
function Parallel (in a1, in b1, in c1, in d1, in a2, in b2, in c2, in d2)
 Parallel connects two state space models. More...
 
function PDDesign (in zeta, in wN, in wD, in inr, in tSamp, in sType)
 Design a PD controller. More...
 
function PGains (in g, in k, in w)
 Compute the principal gains for a system. More...
 
function PhasePlane (in v, in x, in k, in db, in rl)
 Implements a phase plane controller. More...
 
function PID (in kF, in kP, in kR, in kI, in omegaR, in tSamp, in sType)
 Design a PID controller. More...
 
function PIDesign (in zeta, in wN, in inr, in tSamp, in sType)
 Design a PI controller. More...
 
function PIDMIMO (in inr, in zeta, in omega, in tauInt, in omegaR, in tSamp, in sType)
 Produces a state space n degree of freedom PID controller. More...
 
function PIDProper (in KP, in KI, in KD, in wR, in w)
 Compute proper and non-proper transfer functions for a PID. More...
 
function PIDWithLag (in d)
 Creates a PID controller with lag compensation. More...
 
function PILeaky (in k0, in kInf, in w0Db, in tSamp, in sType)
 Design a leaky PI controller. More...
 
function PrintEigenvalues (in g, in f, in t)
 Print eigenvalues to the command window. More...
 
function PropStateSpace (in g, in x, in u)
 Propagate a state space model. More...
 
function PWM (in tau, in tSamp, in n)
 Create a model of a pulsewidth modulator using Padé approximants. More...
 
function QCE (in a, in c, in q, in r, in b, in n)
 Create an estimator from a state space system. More...
 
function QCR (in a, in b, in q, in r, in n)
 Creates a linear quadratic regulator from a state space system. More...
 
function Quant (in x, in lsb, in rType)
 Quantizes a matrix using user defined rounding. More...
 
function Riccati (in g)
 Solves the matrix Riccati equation. More...
 
function RootLocus (in g, in k)
 Generate the root locus for s SISO system. More...
 
function RootSort (in r)
 Sort columns of roots for Root Locus. More...
 
function RouthArray (in p)
 Computes the Routhian array for a polynomial. More...
 
function S2Damp (in s)
 Eigenvalues to damping and natural frequency. More...
 
function S2Z (in a, in b, in c, in d, in dT, in sType)
 Transform an s-plane transfer function into the z-plane. More...
 
function SelectS (in a, in b, in c, in d, in kS, in kO, in kI)
 Extract selected states from a state space model. More...
 
function Series (in a1, in b1, in c1, in d1, in a2, in b2, in c2, in d2)
 Series connects two state space models. More...
 
function ShapeFlt (in wN, in width, in depth, in wL, in tSamp, in sType)
 Generates a shaping filter with notches and first order roll off. More...
 
function SizeAB (in a, in b)
 Checks the dimensions of the set a, b for consistency. More...
 
function SizeABCD (in a, in b, in c, in d)
 Checks the dimensions of the set a,b,c,d for consistency. More...
 
function SizeAC (in a, in c)
 Checks the dimensions of the set a, c for consistency. More...
 
function SRiccati (in g)
 Solves the matrix Riccati equation. More...
 
function SS2ND (in a, in b, in c, in d, in iu)
 Converts from state space to numerator denominator form. More...
 
function SSEmpty ()
 Creates an empty state space system. More...
 
function SSFromNonlinear (in f, in x, in t, in u, in kUse, in varargin)
 Computes state space matrices from a nonlinear function. More...
 
function StatePrp (in a, in b, in c, in d, in x, in u, in sType)
 Propagates state equations. More...
 
function SteadyS (in a, in b, in c, in d, in y, in q, in r)
 Determine the steady state control for a state space system. More...
 
function Step (in g, in iU, in dT, in nSim, in inputType, in statesFlag)
 Generate a step response of a state space system. More...
 
function SVPlot (in g, in w)
 Computes the maximum and minimum singular values. More...
 
function TResp (in g, in x0, in u, in dT, in T)
 Compute the time response of a state-space system. More...
 
function TrnsZero (in a, in b, in c, in d)
 Computes the transmission zeros of a plant. More...
 
function TTPlots (in mag, in w, in t, in gU, in title)
 Generates torque transmission plots. More...
 
function Windup (in a, in b, in c, in d, in p, in sType)
 Implements anti windup compensation. More...
 
function WPZ (in a, in b, in c, in d, in n, in iu, in iy)
 Frequency vector with complex poles and zeros. More...
 
function WReson (in lmin, in lmax, in n, in w)
 Creates a frequency vector with points around resonances. More...
 
function Z2Damp (in z, in T)
 Z domain to s domain damping and natural frequency. More...
 
function Z2S (in f, in g, in h, in j, in dT, in sType)
 Transform an z-plane transfer function into the s-plane. More...
 
function ZFresp (in num, in den, in n)
 Generates the frequency response for a digital filter. More...
 
function ZOH (in T, in n)
 Create a model of a zero-order-hold using Padé approximants. More...
 
function AddOuterLoop (in gInner, in gOuter, in e)
 Add an outer loop for a controller. More...
 
function AssembleBlock (in x)
 Assemble a block given the data structure. More...
 
function AssemblePlant (in gIn, in e, in in, in openLoop)
 Assemble a plant given a model described by gIn. More...
 
function BlockDiagramPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a BlockDiagram GUI plug in. More...
 
function ControlDesignGUI (in action, in modifier, in u)
 Design control systems using a GUI. More...
 
function DualListPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create dual lists. More...
 
function EigenstructurePlugIn (in action, in modifier, in hFig, in position, in callback)
 Create an Eigenstructure GUI plug in. More...
 
function EmptyBlock ()
 Produce an empty data structure used by the control functions. More...
 
function EmptySISO ()
 Produce an empty data structure used by the control functions. More...
 
function LQPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create an LQ plug in for the ControlDesignGUI. More...
 
function MapIOPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create an MapIO plug in for the ControlDesignGUI. More...
 
function ModalReductionPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a ModalReduction plug in for the ControlDesignGUI. More...
 
function ModalTransform (in g)
 Transform the system a,b,c,d into modal form. More...
 
function ModelPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create an Model GUI plug in. More...
 
function ReduceModal (in g, in k)
 Retain modes k of the system a,b,c,d. More...
 
function ReduceOrder (in g, in k)
 Retain states k of the system a,b,c,d. More...
 
function ReduceOrderPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a model order reduction GUI plug in. More...
 
function SISOListPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a list of SISO elements for use by control design tools. More...
 
function SISOPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create an SISO GUI plug in. More...
 
function BuildConstant (in name)
 Build the constant database. More...
 
function Constant (in q, in gUICode)
 Outputs the value of a constant or opens a GUI for searching. More...
 
function Database (in q, in gUICode)
 GUI to output the value of a constant. More...
 
function MergeConstantDB (in action, in a, in b)
 Merges b into a using a GUI. More...
 
function DoubleIntegratorRHS (in x, in ignoredArg, in u, in mass)
 Right hand side for a double integrator. More...
 
function FNLSpring (in x, in ignoredArg, in fData)
 Nonlinear estimator spring model. More...
 
function HNLSpring (in x, in ignoredArg, in hData, in ignoredArg)
 Nonlinear estimator measurement spring model. More...
 
function MeasSpring (in x, in ignoredArg)
 Spring measurement. More...
 
function OscillatorRHS (in x, in ignoredArg, in u, in mass, in omega)
 Right hand side for a spring. More...
 
function RHSDoubleIntegrator (in x, in ignoredArg, in u, in mass)
 Right hand side for a double integrator. More...
 
function RHSNLSpring (in x, in ignoredArg, in d)
 Nonlinear estimator spring model. More...
 
function RHSOscillator (in x, in ignoredArg, in u, in mass, in omega)
 Right hand side for a spring. More...
 
function RHSSpring (in x, in ignoredArg, in d)
 Computes the right hand side for a linear spring. More...
 
function RHSX (in x, in ignoredArg, in d)
 Right hand side for a one dimensional vertical motion simulation. More...
 
function AngleSensor (in x, in d)
 Angle sensor. More...
 
function CDKF (in d, in fName, in hName)
 Continuous discrete iterated extended Kalman Filter. More...
 
function CWPAModel (in dT)
 Continuous Wiener process acceleration (CWPA) model. More...
 
function EKFPredict (in d)
 Extended Kalman Filter prediction step. More...
 
function EKFUpdate (in d)
 Extended Kalman Filter measurement update step. More...
 
function FXNLSpring (in x, in ignoredArg, in d)
 Jacobian of RHSUKF. More...
 
function IEKFUpdate (in d)
 Iterated Extended Kalman Filter measurement update step. More...
 
function IMMPredict (in d)
 Interactive Multiple Models prediction step. More...
 
function IMMUpdate (in d)
 Interactive Multiple Models update step. More...
 
function KalmanFilterCombine (in xB, in pB, in xF, in pF)
 Combine forward and backward covariances and states. More...
 
function KFilter (in r, in phi, in q, in h, in x, in z, in p, in gamma, in u, in s)
 Mechanizes one step of a Kalman Filter with a forgetting factor. More...
 
function KFInitialize (in type, in varargin)
 Initializes Kalman Filter data structures for the KF, UKF, EKF and IEKF. More...
 
function KFPredict (in varargin)
 Linear Kalman Filter prediction step. More...
 
function KFUpdate (in varargin)
 Linear Kalman Filter measurement update step. More...
 
function MeasNLSpring (in x, in d)
 Computes nonlinear spring measurement. More...
 
function MeasPartialNLSpring (in x, in d)
 Computes nonlinear spring measurement partial derivative. More...
 
function RHSPartialNLSpring (in ignoredArg, in ignoredArg, in d)
 Nonlinear estimator spring model. More...
 
function RTSS (in mP, in pP, in m, in p, in a)
 Rauch-Tung-Striebel smoothing. More...
 
function SigmaPointsChol (in d, in p, in varargin)
 UKF sigma points using chol. More...
 
function Symmetrize (in p)
 Makes a square matrix symmetric by adding its transpose and dividing. More...
 
function UDKalmanFilter (in action, in d, in z)
 Implements a Kalman filter using UD factorization. More...
 
function UKF (in action, in d, in y, in verbose)
 Implement an Unscented Kalman Filter. More...
 
function UKFP (in action, in d, in y)
 Implement an Unscented Kalman Filter for parameter estimation. More...
 
function UKFPredict (in d)
 Unscented Kalman Filter state prediction step. More...
 
function UKFRTSS (in m, in p, in d)
 Rauch-Tung-Striebel smoothing for an Unscented Kalman Filter. More...
 
function UKFUpdate (in d)
 Unscented Kalman Filter measurement update step. More...
 
function UKFUT (in m, in p, in c, in wM, in w, in fun, in dFun)
 Unscented Kalman Filter transform. More...
 
function UKFWeight (in d)
 Unscented Kalman Filter weights. More...
 
function UKUDF (in action, in d, in y)
 Implement an Unscented Kalman Filter in UD (upper diagonal) form. More...
 
function DateChanged (in date, in directory)
 Find a list of files in the directory who have been modified after. More...
 
function FileFullpath (in filename, in overwrite)
 Save the file at the path of the calling function. More...
 
function FindDirectory (in d, in ignoredArg)
 Returns the path to a directory. More...
 
function FindInFiles (in string, in caseSensitive, in wholeWord, in includeComments, in fileSet)
 Find all files that contain a specified string. More...
 
function FindRequiredFiles (in FunctionIn, in DirectoryIn, in verbose)
 Find the files required by a function or a script in order to run. More...
 
function FindStringInFiles (in z, in d)
 Finds all instances of the string z in directory d. More...
 
function FirstLineOfCode (in filename)
 Return the first line of code for a m-file. More...
 
function FixLineEndings (in s)
 Make line endings consistent with the platform. More...
 
function GetFileRoot (in s)
 Get the root name of a file (without the .xxx) More...
 
function GetFileSuffix (in s)
 Get the suffix of a file, i.e. More...
 
function GetHeaders (in p)
 Finds all files in the directory d. More...
 
function GetModificationDate (in fileName, in p)
 Gets the modification date. More...
 
function IsFunction (in filename)
 Determine whether a file is a function or script. More...
 
function OpenFile (in path, in file, in suffix, in heading, in permission)
 Open a file using a GUI if it is not specified. More...
 
function PathDirectories ()
 Generate a cell array list of all directories in the Matlab path. More...
 
function RemoveContentsFile (in x)
 Removes the 'Contents.m' file from a cell array of file names. More...
 
function AddToList (in h, in s, in n)
 Add an item to a uicontrol listbox. More...
 
function AddToPath (in dirName)
 Add a local directory to the path and return to the current directory. More...
 
function AllCaps (in s)
 Determines if the string is all capital letters. More...
 
function ArrayToLinspace (in x)
 Converts an array a s function string. More...
 
function AssignFHandle (in fName)
 Assign either a string or function handle depending on the MATLAB version. More...
 
function Cell2DToStruct (in y, in m)
 Convert a structure into a cell array where columns of the array. More...
 
function CellToMat (in c)
 Converts a cell array to a matrix. More...
 
function CenterFigure (in width, in height)
 Find a position array that centers a figure. More...
 
function ChangePath (in newPath)
 Change the path. More...
 
function CloseFigure (in h)
 Close a figure. More...
 
function CloseIfHandle (in h)
 Close h if it is a handle to a figure. More...
 
function CloseMatFile (in kOpenPre)
 Closes every file not listed in kOpenPre. More...
 
function CloseUIElement (in h)
 Close a UIElement. More...
 
function ColumnSizeCellArray (in m, in f)
 Outputs the size of each column of a cell array. More...
 
function ConvertFortranFormatToC (in f)
 Convert Fortran formats to C. More...
 
function CPIAdjust (in cC, in yearC, in yearN)
 Consumer Price Index adjustment. More...
 
function CreateHTMLTable (in x, in fileName, in fString, in title)
 Creates an HTML table from x. More...
 
function CreateLatexTable (in x, in fileName, in fString, in title)
 Creates a LaTeX table from x. More...
 
function CreateTable (in x, in fileName, in fString, in sep)
 Creates a table from x for displaying to the command line. More...
 
function DeBlankAll (in s)
 Delete all blanks. More...
 
function DeBlankLT (in s)
 Delete leading and trailing blanks. More...
 
function DebugLog (in msg, in fullPath)
 Display a message to help debugging. More...
 
function DeleteCell (in c, in k)
 Delete a cell element of a one dimensional cell array. More...
 
function DeleteFromList (in h)
 Delete the selected item from a list. More...
 
function DeleteIfHandle (in h)
 Close h if it is a handle. More...
 
function DeleteSuffix (in x)
 Deletes the .xxx part of a name. More...
 
function DirToCell (in path, in y)
 Converts a directory list into a cell array. More...
 
function DisplayLatexTable (in s)
 Displays a LaTeX table. More...
 
function DispWithTitle (in x, in t)
 Display a variable with a title. More...
 
function EditScroll (in action, in modifier, in hFig, in position)
 Implement a scrollable edit window. More...
 
function Equal (in a, in b)
 Returns one if a and b are identical. More...
 
function fixpopupuicontrol (in fig)
 This function found on Mathworks website as a bug-fix for MATLAB 7. More...
 
function flength (in f)
 Give the length of a file in bytes. More...
 
function Fractal (in v, in f, in n, in sigma)
 Generates fractals. More...
 
function FSWClock (in action, in d)
 This routine implements the flight software clock. More...
 
function FunNames (in path)
 Get Function Names. More...
 
function GetCurrentGUIObject (in hFig)
 Gets the last uicontrol that was hit. More...
 
function GetEntry (in h, in d, in errMsg)
 Gets the input from a vector of graphics handles and determines. More...
 
function GetInputFromString (in s)
 Generates an output from a string. More...
 
function GetListString (in h)
 Get an element from a list uicontrol. More...
 
function GetNewTag (in name)
 Get a new tag to uniquely identify a figure. More...
 
function GetUIElement (in h, in property)
 Get certain properties of UIElements. More...
 
function HasOptimizationToolbox ()
 Returns 1 if a licensed optimization toolbox is in your path. More...
 
function Inflation (in from, in to)
 Computes U.S. More...
 
function IntToBinary (in i)
 Converts an integer to binary [lsb msb] in two's complement. More...
 
function IsValidField (in m, in s)
 Determine if a field exists and is not empty. More...
 
function IsVersionAfter (in n)
 Checks to see if the version of MATLAB is after n. More...
 
function IsVersionBefore (in n)
 Checks to see if the version of Matlab is before n. More...
 
function LatexExp (in n, in f)
 Creates a latex exponential string. More...
 
function LatexScientificNotation (in x, in n, in m)
 Converts a number into a string using latex notation. More...
 
function LatexTableFromStructure (in s, in f, in u)
 Creates a LaTeX table from s. More...
 
function ListCases (in filename, in beQuiet, in first)
 List the switch cases that are included in a given file. More...
 
function ListFunctions (in filename, in level, in noMatlabFuns, in method)
 List the functions that are called from a given file. More...
 
function ListMemberFunctions (in filename, in verbose)
 List the member functions that are included in a given function/file. More...
 
function ListParents (in fcn, in folder, in recursive)
 List all parents of a function. More...
 
function LogB (in b, in x)
 Log base b. More...
 
function MatrixCellTo3D (in c)
 Convert a cell array of p x p matrices into a 3D matrix. More...
 
function MatrixDisplay (in x, in f)
 Display a matrix using the format f. More...
 
function MatToCell (in m)
 Converts a string matrix to a cell array. More...
 
function Num2Str1Line (in n, in d)
 Converts a matrix to a one line string. More...
 
function PrintTitle (in t)
 Print a title with — under and above. More...
 
function ProcessTag (in action, in tag, in k, in name)
 Code used to process tags for sensors and actuators. More...
 
function RadioButtons (in action, in modifier, in hFig, in position, in rows, in format, in cB)
 Create radio buttons. More...
 
function RequiredFields (in g, in r)
 Returns 1 if the data structure g has the required fields in r. More...
 
function SaveMovie (in m, in fileName)
 Save a MATLAB movie. More...
 
function SaveStructure (in gXXXX, in fileName)
 Save a structure in a file. More...
 
function SetUIElement (in h, in varargin)
 Set certain properties of UIElements. More...
 
function SortColumnCell (in x)
 Sort a nxm cell array by the values in the first column. More...
 
function Staircase (in t, in dT, in varargin)
 Generates steps for any number of inputs. More...
 
function StringMatch (in s, in sA, in ignoredArg)
 Finds which elements of sA match s. More...
 
function StringToToken (in s)
 Finds the first token in a string. More...
 
function StringToTokens (in s, in delimiters, in noSpace)
 Converts a string to a list of tokens. More...
 
function StrMtch (in s, in sM)
 In a matrix with each row a string finds the first matching string. More...
 
function StructToCell2D (in x)
 Convert a structure into a cell array. More...
 
function StructToText (in data, in textFileName)
 Write data structure to a text file or command line display. More...
 
function StructureList (in action, in modifier, in d, in name, in position, in hFig)
 Creates a list of structures and variables. More...
 
function UIElement (in varargin)
 Interface to PSS and Mathworks UI. More...
 
function ValidTime (in t)
 Returns the time if valid. More...
 
function WaitBarManager (in action, in d)
 Manages the wait bar. More...
 
function Watermark (in string, in fig, in pos, in color)
 Add a watermark to a figure. More...
 
function AddAxes (in m, in r, in T, in h, in c, in label)
 Adds x,y,z coordinate axes to a figure. More...
 
function AddDeltaModeToPlot (in hAxis, in oldMode, in newMode, in t, in x)
 Add mode changes to a plot. More...
 
function AddFillToPlots (in time, in data, in h, in colors, in alpha)
 Find mode changes in data and draw as filled sections on existing plots. More...
 
function AddView (in h)
 Add view accelerators to a figure. More...
 
function AddZoom (in h)
 Add zoom-in (CTRL+I) and zoom-out (CTRL+O) accelerators to a figure. More...
 
function AnglePatch (in v1, in v2, in z, in c, in f)
 Draw a patch showing the inner angle between two vectors. More...
 
function AnimateCube (in action, in modifier, in x)
 Draw a cube given its dimensions. More...
 
function AnimateVectors (in varargin)
 Animate one or more time-varying vectors. More...
 
function Animator (in fig, in data, in background, in style, in markersize, in linewidth)
 Animate a set of 2xN or 3xN matrices over N steps. More...
 
function Arrow3D (in r, in l, in g, in u, in c, in alpha, in hA)
 Draws a 3D arrow into an existing figure. More...
 
function AssignColors (in n, in sat, in val)
 Choose n colors from around the RGB color wheel. More...
 
function AttitudeCoordinates (in varargin)
 Draw attitude coordinates. More...
 
function AxesCart (in xMin, in yMin, in zMin)
 Draw axes on the current plot with X, Y, Z, text labels. More...
 
function Axis3D (in s)
 Adjust 3D axes properties. More...
 
function AxisEqual (in axisHandle, in minSize, in dim)
 Equalize the axes with a minimum relative size for the smallest axis. More...
 
function BarPlot (in x, in y)
 Creates a bar plot of x. More...
 
function CameraControls (in varargin)
 This function creates a GUI for manipulating the camera view. More...
 
function Centroid (in v)
 Compute a centroid from a set of vertices. More...
 
function Circle (in r, in xc, in yc, in n)
 Compute x y data for a 2-D Circle. More...
 
function ColorMapGrayScale ()
 Generates a gray scale colormap with 256 entries. More...
 
function ColorSpread (in n, in map)
 Produce a set of 3-element RGB colors that spread across the colormap. More...
 
function ConvertOBJFileColorToMatlab (in m)
 Converts the Wavefront OBJ color format to MATLAB. More...
 
function Coordinates (in m)
 Creates a figure with x,y,z coordinates at the origin. More...
 
function DiskWithHole (in rI, in rO, in n, in z)
 Draw a disk. More...
 
function DistanceLabel (in d)
 Rescales distances. More...
 
function DrawCAD (in g, in drawNormals, in scale)
 Draw a CAD model stored in the toolbox CAD format. More...
 
function DrawFOV (in f, in l, in axesHandle)
 Draw fields of view. More...
 
function DrawImage (in hParent, in position, in file, in path, in width)
 Draws an image in a figure window. More...
 
function DrawSphere (in R, in surfCol, in lineCol, in latMarks, in longMarks)
 Draw a sphere with specified latitude and longitude lines. More...
 
function DrawTreeDiagram (in hFig, in tree, in position, in buttonDownFunction)
 Creates and draws a tree diagram. More...
 
function DrawVertices (in v, in f, in name, in blend)
 Draw and object from vertices in a figure window using patch. More...
 
function Ellipsd (in a, in b, in c, in n)
 Generates an ellipsoid using the equation. More...
 
function GPoly ()
 Graphical interface to create a polygon. More...
 
function ImageOverlay (in x, in wData, in tBoxes)
 This function displays an image file and overlays text boxes. More...
 
function IntersectPlaneAndSphere (in r, in plane, in n)
 Finds the vector giving the intersection. More...
 
function LabelLine (in x, in t, in n, in f)
 Labels a line. More...
 
function LabelS (in x, in y, in z, in font)
 Creates 2 or 3 axis labels. More...
 
function LegendTitle (in name, in size)
 Add a title to the current legend. More...
 
function LegendWithTitle (in s, in title, in varargin)
 Create a legend with a title. More...
 
function Loc3D (in p, in u, in cM)
 Plot the location of points. More...
 
function LogLimit (in wV)
 Given a frequency vector, find the logarithm of the frequency. More...
 
function Map (in planet, in mType, in ignoredArg)
 Draws a 2 or 3 dimensional map of a planet. More...
 
function Mesh2 (in xCol, in yRow, in z, in xLbl, in yLbl, in zLbl, in figTitle)
 Draws mesh plots with axis labels. More...
 
function Mesh3DMF (in v, in vM, in fileName, in colorAtt)
 Generate a 3DMF file for a mesh. More...
 
function MeshSOR (in fZOfR, in nTheta, in nR, in rMax)
 Create a polygonal mesh from a surface of revolution. More...
 
function MeshToPatch (in x, in y, in z, in vIn, in fIn)
 Convert a mesh to a patch. More...
 
function NewFig (in x, in varargin)
 Creates a new figure. More...
 
function Normal (in v)
 Compute a normal from a set of vertices using the Newell method. More...
 
function NPlot (in yLabels, in y, in x, in xAxisLabel, in yAxisLabel, in plotTitle, in figTitle)
 NPlot generates a plot on which the ylabels are character strings. More...
 
function PlaybackControls (in valMin, in valMax, in val0, in callback, in dx, in name, in position)
 Create a GUI with playback controls. More...
 
function Plot2D (in x, in y, in xL, in yL, in figTitle, in plotType, in iY, in iX, in nCols, in pThresh, in figBackColor, in leg)
 Easily build a versatile 2D plot page consisting of any number of plots. More...
 
function Plot3D (in r, in xL, in yL, in zL, in figTitle, in rPlanet, in figBackColor)
 Create a 3-dimensional plot. More...
 
function Plot3Vector (in time, in vector, in title)
 Plot a 3 vector as x, y, z subplots as well as a combined plot. More...
 
function PlotAngleRange (in varargin)
 Plot one or more angular ranges on a unit circle. More...
 
function PlotArrays (in action, in d, in varName, in varargin)
 Manage a set of arrays for plotting simulation data. More...
 
function PlotColor (in k)
 Generate [r, g, b] for an index k = 1 to 100. More...
 
function PlotDoubleYAxis (in x, in yL, in yR, in xLabel, in yLabelL, in yLabelR, in title, in name, in tL, in tR)
 Generates a plot with two y axes. More...
 
function PlotF (in action, in y, in t, in g)
 Create any number of plot pages in one call. More...
 
function PlotSet (in x, in y, in varargin)
 Create two-dimensional plots from a data set. More...
 
function PlotV (in x, in xLbl, in yLbl, in zLbl, in figTitle)
 Draws plots of a set of 3*m-by-n vectors in 3D axes. More...
 
function PltStyle ()
 Edit this to globally change the plot styles for the plot labels. More...
 
function Polygon (in v)
 Generate the properties for a polygon given vertices in the form v(3,n). More...
 
function PolygonProps (in v, in f)
 Polygon properties from vertex and face data. More...
 
function PositionLabel (in x)
 With an input in meters give a reasonable output scale. More...
 
function PrintFig (in invertHardCopy, in printType, in f, in fName, in pathName, in zBuffer)
 Prints specified figures to a printer or files. More...
 
function RealTimePlot (in action, in y, in t, in g)
 Plot real time. More...
 
function Rename (in x, in f)
 Renames a figure title. More...
 
function SetFont (in name, in size, in angle, in style)
 Sets default fonts. More...
 
function ShowThreeImages (in x, in y, in z, in title)
 Display three images. More...
 
function SliderBar (in valMin, in valMax, in val0, in callback, in name, in position, in fig)
 Create a slider in a new figure with continuous calls to callback. More...
 
function SortFigs (in h, in xo)
 Sort figure windows by cascading them. More...
 
function Splash ()
 Draw a splash screen. More...
 
function StateDisplay (in action, in varargin)
 Draw a 3D covariance display in real-time. More...
 
function TextInBox (in pos, in s, in varargin)
 Draw text in a box. More...
 
function TextS (in x, in y, in s, in k)
 Prints labels on a graph using text with toolbox style settings. More...
 
function TimeHistory (in t, in y, in yL, in figTitle, in yList, in leg)
 Time history plots. More...
 
function TimeLabel (in t0)
 Produce time labels and scaled time vectors. More...
 
function TimeLabl (in t0, in dT)
 Generates a time label given the maximum value of t and rescales t. More...
 
function TitleS (in x, in font)
 Creates a title using the toolbox style settings. More...
 
function TreeDiagram (in n, in w, in update, in withTrackIDs)
 Generates a tree diagram. More...
 
function VantagePoint (in x, in y, in A, in g, in color)
 Adds vantage points to an existing plot. More...
 
function VelocityLabel (in v)
 With an input in meters/s give a reasonable output scale. More...
 
function View3D (in type)
 View a plane of a 3D plot or standard cartesian view. More...
 
function XLabelS (in x, in font)
 Creates an xlabel using the toolbox style settings. More...
 
function YLabelS (in x, in font)
 Creates a ylabel using the toolbox style settings. More...
 
function ZLabelS (in x)
 Creates a zlabel using the toolbox style settings. More...
 
function EditDlg (in string, in defaultString, in waitTime)
 Creates a dialog which requires a string as an answer. More...
 
function Figui (in h, in fs, in pos)
 User-interface to manage figure windows. More...
 
function Finder (in action, in modifier)
 GUI to find occurrences of a text string in m-files on your MATLAB path. More...
 
function GUIColors (in action, in modifier)
 GUI for setting interface colors. More...
 
function InformDlg (in text, in title)
 Create an information dialog that will be dismissed by a script. More...
 
function LegendFig (in names, in colors, in figTitle)
 Produce a new figure with just a legend of colors and names. More...
 
function MessageQueue (in action, in modifier, in msg, in ignoredArg)
 Creates a message queue GUI. More...
 
function MLog (in action, in text, in index)
 Message log. More...
 
function ODETimeDisplay (in time, in ignoredArg, in action, in varargin)
 Displays an estimate of time to go, compatible with ode113. More...
 
function Selection (in list, in msg, in name)
 Selection GUI. More...
 
function SetCopy (in k, in w, in h)
 Set the dimensions of the figure when copied or printed. More...
 
function StopGUI (in name)
 GUI for stopping scripts. More...
 
function TabBox (in action, in modifier, in tabs, in content, in position, in hFig, in formatInfo, in data, in callback)
 Create a tab box from plug-ins. More...
 
function TimeCntrl (in action)
 Perform actions specified by the time display. More...
 
function TimeDisplay (in action, in varargin)
 Displays an estimate of time to go. More...
 
function TimeGUI (in totalSteps, in stepsDone, in tToGoMem, in rRT, in dT, in name)
 A GUI displaying the time remaining and estimated completion time. More...
 
function TimeToGo (in totalSteps, in stepsDone, in tToGoMem, in rRT, in dT)
 Computes the time left to go in the simulation, the predicted finish. More...
 
function ExportToPSSMatrix (in fileName, in varargin)
 Export two dimensional matrices to a file that can be read by pss_matrix. More...
 
function LoadSimLog (in file)
 Reads data from a simulation log file. More...
 
function QuickPlot (in file)
 Plots output data from external simulations. More...
 
function ReadCSVTable (in filename)
 Read in tabular data in .csv file and convert it to a structure array. More...
 
function SFunc (in t, in x, in u, in flag)
 An example s-function that interfaces mfiles to Simulink. More...
 
function STKAtt (in fileName, in ver, in epoch, in nPoints, in time, in attitude, in type, in seq)
 Prints attitude data to STK-formatted file. More...
 
function STKOrbit (in fileName, in ver, in epoch, in nPoints, in time, in position, in velocity, in type)
 Prints orbit data to STK-formatted file. More...
 
function VCFlatFile (in fileName, in time, in varargin)
 Write a set of variables to a VC flat file (comma-separated with header). More...
 
function WriteCM (in fID, in matName, in m, in x, in nD, in nT, in nPR)
 Write a matrix for use in a C or C++ program. More...
 
function AddMass (in mA, in mB, in u)
 Add mass properties. More...
 
function IC623X3 (in x)
 Convert an inertia matrix from a 1x6 to a 3x3 format. More...
 
function InertiaFromOBJFile (in fileName, in mass, in scale, in c)
 Computes an inertia matrix from an obj file or data structure. More...
 
function Inertias (in m, in x, in type, in ignoredArg)
 Computes inertias of common objects about their c.m. More...
 
function MassProp (in inr, in m, in cM, in u, in cName, in c)
 Compute inertia, mass and center of mass for a collection of rigid bodies. More...
 
function MassPropertiesSolidObjFile (in fileName, in mass, in scale)
 Computes a mass properties data structure from an obj file. More...
 
function MassPropertiesTetrahedron (in v, in rho)
 Compute inertia, volume and center of mass of a uniform tetrahedron. More...
 
function MassStructure (in mass, in type, in info, in cM)
 Create a mass data structure. More...
 
function PrincipalAxes (in inertia, in u)
 Computes the principal axes for an inertia matrix. More...
 
function VFToMassStructure (in v, in f, in d)
 Computes mass properties for a component defined by vertices and faces. More...
 
function Volumes (in x, in type)
 Computes volumes of common objects about their c.m. More...
 
function AtomicMass (in atom, in units)
 Outputs atomic mass in kg or amu. More...
 
function CPGas (in t, in gas)
 Thermal capacity for a gas as a function of temperature. More...
 
function GasProperties (in gas)
 Returns gas properties. More...
 
function PoissonsRatio (in material)
 Returns Poisson's ratio. More...
 
function ComputeGainsPlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a detection filter gains GUI plug in used by DetectionFilterBuilder. More...
 
function HierarchicalListPlugIn (in action, in modifier, in hFig, in position, in callback, in params)
 Create and manages a hierarchical list. More...
 
function NormalizePlugIn (in action, in modifier, in hFig, in position, in callback)
 Create the Normalize GUI plug in used by DetectionFilterBuilder. More...
 
function PlotPlugIn (in action, in modifier, in hFig, in position)
 Plot a variable number of points. More...
 
function SimulatePlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a Simulate GUI plug in used by DetectionFilterBuilder. More...
 
function StateSpacePlugIn (in action, in modifier, in hFig, in position, in callback)
 Create an StateSpace GUI plug in used by DetectionFilterBuilder. More...
 
function Telemetry (in action, in modifier, in u, in v)
 Generates a GUI with a set of telemetry pages. More...
 
function TelemetryOffline (in action, in modifier)
 This GUI plots telemetry files previously saved by Telemetry. More...
 
function TelemetryPlot (in action, in modifier, in u)
 Plot real time data in a single window. More...
 
function TimePlugIn (in action, in modifier, in hFig, in position, in callback)
 Create a time GUI plug in. More...
 
function HoopStress (in r, in p, in sigma, in type)
 Computes the thickness of a pressure vessel. More...
 
function MassPressureVessel (in d, in t, in rho, in type)
 Computes the mass of a pressure vessel. More...
 
function Anim2Q (in q, in speed, in h, in propName, in propValue)
 Animate the evolution of 2 quaternions over time. More...
 
function AnimQ (in q, in speed, in h, in propName, in propValue)
 Animate the evolution of a quaternion over time. More...
 
function AU2Q (in angle, in u)
 Convert an angle and a unit vector to a quaternion. More...
 
function DeltaQToRate (in q1, in q2, in dT)
 Angular rate from small quaternion changes. More...
 
function DQ2Mat (in q, in qDot)
 Finds the derivative of a transformation matrix in terms of quaternions. More...
 
function Mat2Q (in m)
 Converts a transformation matrix to a quaternion. More...
 
function Q2AU (in q)
 Convert a quaternion to an angle and a unit vector. More...
 
function Q2Eul (in q, in e)
 Converts a quaternion to 3-2-1 Euler angles. More...
 
function Q2Mat (in q)
 Converts a quaternion to a transformation matrix. More...
 
function QAxisRot (in qi, in angle, in u)
 Creates a quaternion based on a pure rotation about the any axis. More...
 
function QBToIDot (in q, in w, in dT)
 Computes the quaternion derivative from angular velocity. More...
 
function QError (in qRef, in qMeas, in ignoredArg)
 Small angle errors between two quaternions. More...
 
function QForm (in q, in ua)
 Transforms a vector in the direction of the quaternion. More...
 
function QFromDQ (in q, in dQ24)
 Computes a quaternion from a base quaternion and delta quaternion. More...
 
function QMult (in Q2, in Q1)
 Multiply two quaternions. More...
 
function QPose (in q)
 Transpose of a quaternion. More...
 
function QRand (in n)
 Generates random quaternions. More...
 
function QTForm (in q, in ua)
 Transforms a vector opposite the direction of the quaternion. More...
 
function QUnit (in q)
 Unitizes a quaternion. More...
 
function QZero ()
 Outputs the zero quaternion, [1;0;0;0]. More...
 
function Sa2Q (in av)
 Converts an angle vector into a quaternion. More...
 
function U2Q (in u, in v)
 Finds the quaternion that aligns a unit vector with a second vector. More...
 
function ReliabilityMOfN (in m, in n, in mTBF, in t)
 Determine the reliability of a system. More...
 
function ReliabilityParallel (in n, in mTBF, in t)
 Determine the reliability of a parallel system. More...
 
function ReliabilitySeries (in n, in mTBF, in t)
 Determine the reliability of a series system. More...
 
function Date2DN (in datetime)
 Compute the day number from the date. More...
 
function Date2FY (in datetime)
 Computes the fractional year from the date. More...
 
function Date2JD (in datetime)
 Compute the Julian Date from the date. More...
 
function DateStringToJD (in s)
 Convert a date string to Julian date. More...
 
function DeltaT (in jd)
 Computes the difference between UT1 and TT based on the Julian date. More...
 
function DN2Date (in dN, in year)
 Computes the date from the day number and year. More...
 
function DN2JD (in dN, in year)
 Computes the Julian Date from the day number and year. More...
 
function DNString2Date (in s)
 Converts a day number string to a date. More...
 
function DTAToDTS (in t)
 Converts the date time array to the date time structure. More...
 
function DTSToDTA (in t)
 Converts the date time structure to the date time array. More...
 
function FindSolsticeOrEquinox (in type, in year)
 Finds the Julian Date for solstices and equinoxes. More...
 
function JD2000 ()
 Returns the Julian Date for J2000.0 0d 0h UT. More...
 
function JD2Array (in jD0, in t)
 Compute an array of Julian dates from an epoch. More...
 
function JD2Date (in jd, in structOut)
 Compute the calendar date from the Julian date. More...
 
function JD2Day (in jD)
 Computes the day of the week from Julian day number. More...
 
function JD2DN (in jD)
 Compute the day number from Julian date. More...
 
function JD2MJD (in jD)
 Converts Julian date to Modified Julian Date. More...
 
function JD2T (in jd)
 Converts Julian days to centuries from J2000.0. More...
 
function JDToDateString (in jD, in ignoredArg)
 Convert Julian Date to the form '04/20/2000 00:00:00'. More...
 
function JDToMidnight (in jD)
 Converts a Julian date to the nearest midnight. More...
 
function LeapYear (in datetime)
 Determines if a year is a leap year. More...
 
function LocalTimeToGMT (in dateTime, in lon)
 Compute the Julian Date from the local time. More...
 
function LocalTimeToJD (in dateTime, in lon)
 Compute the Julian Date from the local time. More...
 
function MJD2JD (in mJD)
 Converts Modified Julian Date to Julian date. More...
 
function SecToString (in s)
 Convert seconds to days hours/min/seconds and produces a string. More...
 
function SystemTime (in action, in mET, in jD)
 Provides the system time to the software. More...
 
function T2JD (in T)
 Converts Julian centuries from J2000.0 to days. More...
 
function TAI2TT (in tAI)
 Converts Terrestrial atomic time to Terrestrial dynamic time. More...
 
function TDB2TT (in tDB, in jD)
 Converts barycentric dynamical time. More...
 
function TimeStringToJD (in s)
 Convert a time string to Julian date. More...
 
function TT2TAI (in tT)
 Converts Terrestrial (dynamic) time to Terrestrial atomic time. More...
 
function TT2TDB (in tT, in jD)
 Converts terrestrial dynamic time to barycentric dynamical time. More...
 
function TT2UT1 (in jDTT)
 Converts TT (Terrestrial (dynamic) Time) to UT1. More...
 
function UT12TT (in jDUT1)
 Converts UT1 (time scale based on the rotation of the earth) More...
 
function YPF2T (in y)
 Converts years in fractional form, e.g. More...
 
function Altitude (in r, in f, in a, in units)
 Computes the altitude above an ellipsoidal planet. More...
 
function AU2M (in angle, in u)
 Convert an angle and a unit vector to a matrix. More...
 
function Cart2Sph (in x, in y, in z)
 Converts cartesian coordinates to spherical. More...
 
function CoordinateFrameFromUV (in u)
 Computes a transformation matrix from the frame. More...
 
function Deg2DMS (in a)
 Convert degrees to degrees, minutes and seconds. More...
 
function Deg2HMS (in a)
 Convert radians to hours, minutes and seconds. More...
 
function DMS2Deg (in d, in m, in s)
 Convert degrees, minutes and seconds to radians. More...
 
function DMS2Rad (in d, in m, in s)
 Convert degrees, minutes and seconds to radians. More...
 
function Eul2Mat (in e)
 Converts 3-2-1 Euler angles into an orthonormal transformation matrix. More...
 
function Eul2Q (in e)
 Converts 3-2-1 Euler angles to a quaternion. More...
 
function EulDot2Rates (in e, in wEul, in n)
 Converts 3-2-1 Euler angle rates into angular velocity. More...
 
function HMS2Deg (in h, in m, in s)
 Convert hours, minutes and seconds to degrees. More...
 
function HMS2Rad (in h, in m, in s)
 Convert hours, minutes and seconds to radians. More...
 
function IConv (in IVec)
 Transform a 6x1 compact inertia vector into a 3x3 inertia matrix. More...
 
function IConvP (in IMat)
 Transform a a 3x3 inertia matrix into 6x1 compact inertia vector. More...
 
function Mat2Eul (in m, in e)
 Converts an orthonormal transformation matrix into 3-2-1 Euler angles. More...
 
function Rad2DMS (in a)
 Convert radians to degrees, minutes and seconds. More...
 
function Rad2HMS (in a)
 Convert radians to hours, minutes and seconds. More...
 
function RaDec2U (in rA, in dec)
 Converts right ascension and declination to unit vectors. More...
 
function Rates2EulDot (in e, in w, in n)
 Converts angular velocity into 3-2-1 Euler angle rates. More...
 
function RotMat (in angle, in axis)
 Generates a rotation matrix that transforms in the opposite direction. More...
 
function RPhiTheta2Cart (in r)
 Computes the transformation matrix from an r, phi, theta frame. More...
 
function Sph2Cart (in r, in theta, in phi)
 Converts spherical coordinates to cartesian. More...
 
function TranslateAxes (in i, in r, in m, in sgn)
 Recompute the moment of inertia "i" by translating axes. More...
 
function UnitVectorFromOffset (in v1, in v2, in cone, in clock)
 Computes a unit vector offset from v2 with origin at v1. More...
 
function VM2Int (in v)
 Converts apparent visual magnitude to intensity in watts/m^2. More...
 

Detailed Description

The Common module functions. View the published Common Demos.

The Common module contains many useful utilities that are used across our product line.

Function Documentation

◆ Acker()

function Acker ( in  a,
in  b,
in  p 
)

Gains for poles using Ackermann's formula.

Computes the gain for desired pole locations using Ackermann's
formula so that a-bk has the desired poles.

Form

k = Acker( a, b, p )


Inputs

a                  Plant matrix
b                  Input matrix
p                  Pole locations

Outputs

k                  Gain            

References: Franklin, G., J.D. Powell, M.L. Workman (1992). Digital

Control of Dynamic Systems. John Wiley & Sons, New York 245.


◆ ACTF()

function ACTF ( in  e)

Generic sensor or actuator model.

The model is

x              exp(-delay*s)
-  = -----------------------------------
u    (s^2 + 2*zeta*w + w^2)*(tau*s + 1 )

Any term may be omitted. Uses a 2nd order delay model.


Form

g = ACTF( e )


Inputs

e           (n)   Sensor data structure
.delay
.tau
.zeta
.w
.name   Name of the device

Outputs

g           (:)   Sensor state space model of type statespace

◆ AddAxes()

function AddAxes ( in  m,
in  r,
in  T,
in  h,
in  c,
in  label 
)

Adds x,y,z coordinate axes to a figure.

Specify the size, location, and orientation of the axes. A label may be given which will be prepended to the axis labels (X,Y,Z).


Form

[h,q] = AddAxes( m, r, T,  h, c, label )


Inputs

m             (1)     Length of all coordinate axes 
(optional, default 1)
r            (3,1)    Vector indicating the origin of the axes 
(optional, default [0;0;0] )
T            (3,3)    Transformation matrix 
(optional, default identity)
Note: a quaternion may be supplied instead
h             (1)     Figure handle 
(optional)
c             (1)     Color scheme for x, y, z
1 - Blue, Green, Red
2 - Black, Cyan, Magenta
or a single color, 'r', 'b'
(optional, default 1)
label         (:)     Text label to add to axes labels

Outputs

h             (1)     Figure handle
q             (.)     Struct of graphics handles

◆ AddDeltaModeToPlot()

function AddDeltaModeToPlot ( in  hAxis,
in  oldMode,
in  newMode,
in  t,
in  x 
)

Add mode changes to a plot.


Form

AddDeltaModeToPlot( hAxis, oldMode, newMode, t, x )


Inputs

hAxis       (1,1) Handle to axis
oldMode     {:}   Old Modes
newMode     {:}   New Modes
t           (:,:) Time of mode transition
x           (3,:) Location

Outputs

None

◆ AddFillToPlots()

function AddFillToPlots ( in  time,
in  data,
in  h,
in  colors,
in  alpha 
)

Find mode changes in data and draw as filled sections on existing plots.

Time and data must be the same size. diff will be used to find the points where the value of data changes. Each segment will then be assigned a background color from colors. The 'auto' colors mode used the axes color order property. If a figure handle is not specified the current figure is used.

Type AddFillToPlots for a demo.


Form

AddFillToPlots(time,data,h,colors,alpha)


Inputs :

time      (1,n)            Time axis data (the same for all subplots)
data      (1,n)            Data containing the mode changes
h         (1,1)            Figure handle with plots
colors    (n,3) or 'auto'  Colors for fill patches
alpha     (1,1)            facealpha property for the patch, in range [0 1]

Outputs :

None.

◆ AddMass()

function AddMass ( in  mA,
in  mB,
in  u 
)

Add mass properties.

mB is optional. mA and/or mB may be arrays of data structures.

Typing AddMass returns the default data structure.


Form

m = AddMass( mA, mB, u )


Inputs

mA          (:)    Mass data structure
.mass    (1,1) Mass
.cM      (3,1) Center-of-mass
.inertia (3,3) Inertia matrix about CM
mB          (:)    Mass data structure
.mass    (1,1) Mass
.cM      (3,1) Center-of-mass
.inertia (3,3) Inertia matrix about CM
u           (1,:)  Units

Outputs

m           (:)    Mass data structure
.mass    (1,1) Mass
.cM      (3,1) Center-of-mass
.inertia (3,3) Inertia matrix

◆ AddOuterLoop()

function AddOuterLoop ( in  gInner,
in  gOuter,
in  e 
)

Add an outer loop for a controller.

Type AddOuterLoop for a demo.


Form

g = AddOuterLoop( gInner, gOuter, e )


Inputs

gInner (1,1) Inner loop plant
gOuter (1,1) Outer loop plant
e      (n,m) Outer to inner loop matrix (m outputs from outer loop
to n inputs) 

Outputs

g      (1,1)  The complete statespace controller

◆ AddToList()

function AddToList ( in  h,
in  s,
in  n 
)

Add an item to a uicontrol listbox.


Form

AddToList( h, s, n )


Inputs

h             (1,1)   Handle to list
s             (1,:)   String to be added
n             (1,1)   Any entry prevents duplicates

Outputs

None    

◆ AddToPath()

function AddToPath ( in  dirName)

Add a local directory to the path and return to the current directory.

This function is designed to be executed from the parent function, i.e. the top of a module


Form

AddToPath( dirName )


Inputs

dirName       (:)    The name of the directory to add. If omitted, the
current directory will be added.

◆ AddView()

function AddView ( in  h)

Add view accelerators to a figure.

Snap to different frames as shown:

x-y   CTRL+J
y-x   CTRL+K
x-z   CTRL+L
y-z   CTRL+M

Form

AddView( h )


Inputs

h                (:)  Handle to the figure (optional, default is gcf)

Outputs

none

◆ AddZoom()

function AddZoom ( in  h)

Add zoom-in (CTRL+I) and zoom-out (CTRL+O) accelerators to a figure.


Form

AddZoom( h )


Inputs

h   (:)  Handle to the figure (optional, default is gcf)

Outputs

none

◆ AggregateComponents()

function AggregateComponents ( in  c,
in  scale 
)

Aggregate CAD component vertices and faces.

This is useful with external models with many components. Once you aggregate them you can rotate and translate the assembly.

Type AggregateComponents for a demo with a Box and a Frustrum.


Form

[v,f] = AggregateComponents(c)


Inputs

c           (:)  Data structure array of components
.v (:,3) Vertices
.f (:,3) Faces
scale       (1,1) Scale factor for the vertices

Outputs

v           (:,3) Vertices, combined from the components
f           (:,3) Faces

◆ Alias()

function Alias ( in  w,
in  ws 
)

Computes the fundamental alias of a frequency.


Form

w = Alias( w, ws )


Inputs

w            (1,:)  Frequency w > ws/2
ws           (1,1)  Sampling frequency

Outputs

w            (1,:)  Fundamental alias

◆ AllanVariance()

function AllanVariance ( in  x,
in  t 
)

Implements the overlapping Allan Variance.

Type AllanVariance for a demo. The simulation takes a long time.


Form

aD = AllanVariance(x,t)


Inputs

x   (1,:)   Data
t   (1,:)   Time vector

Outputs

aD  (1,:)   Allan deviation
a   (1,:)   Allan variance
tAv (1,:)   Averaging times

Reference: Freescale Semiconductor "Allan Variance: Noise Analysis for Gyroscopes, Application Note," Document Number: AN5087, Rev. 0. 2/2015.


◆ AllCaps()

function AllCaps ( in  s)

Determines if the string is all capital letters.

s may be a cell array of strings.


Form

t = AllCaps( s )


Inputs

s             (1,:)   String

Outputs

t             (1,:)   True or false

◆ Altitude()

function Altitude ( in  r,
in  f,
in  a,
in  units 
)

Computes the altitude above an ellipsoidal planet.


Form

h = Altitude( r, f, a, units )


Inputs

r             (3,:)   ECI position vectors (units)
f             (1,1)   Flattening factor
a             (1,1)   Equatorial radius
units         (1,:)   Units, mks or other

Outputs

h             (1,:)   Altitude (units)

◆ AnglePatch()

function AnglePatch ( in  v1,
in  v2,
in  z,
in  c,
in  f 
)

Draw a patch showing the inner angle between two vectors.

Enter a rotation axis if the angle may be more than 180 degrees.


Form

AnglePatch( v1, v2, z, c, f )


Inputs

v1             (3,1)  First vector
v2             (3,1)  Second vector
z              (3,1)  Rotation axis, optional
c              (:)    Color code, 'g', 'r', etc
f              (1,1)  Saturation, between 0 and 1

Outputs

none

◆ AngleSensor()

function AngleSensor ( in  x,
in  d 
)

Angle sensor.

The inputs are the one dimensional state vector [x;v] and a data structure with the baseline and noise. The sensor tracks the target.


Form

theta = AngleSensor( x, d )


Inputs

x       (2,1)   [x;v]
d       (1,1)   Data structure
.b       (1,1)   Baseline
.noise   (1,1)   Angle noise (rad)

Outputs

theta   (1,1)   Angle measurement 

◆ Anim2Q()

function Anim2Q ( in  q,
in  speed,
in  h,
in  propName,
in  propValue 
)

Animate the evolution of 2 quaternions over time.


Form

Anim2Q( q, speed, h, propName, propValue )  


Inputs

q              (8,:)  Time history of two quaternions
speed           (1)   Speed factor (0 slow - 100 fast)
h               (1)   Handle of the figure to animate in (optional)
propName        {:}   Array of property names
ie, {'linewidth','linestyle'}
propValue       {:}   Array of property values
ie, {2,'--'}

Outputs

none

◆ AnimateCube()

function AnimateCube ( in  action,
in  modifier,
in  x 
)

Draw a cube given its dimensions.

The color scheme for the x/y/z faces is blue, green, red, following the default MATLAB color order.


Form

AnimateCube( action, modifier, x )
AnimateCube( 'run', dim, q )
tag = AnimateCube( 'initialize', dim )
AnimateCube( 'update', tag, q )


Inputs

action      (1,:) 'initialize', 'update', 'close'
modifier    (1,:) [x,y,z] dimensions on initialize or tag otherwise
x           (4,1) Quaternion  (used for update/run only), or (5,1) if a
time is appended.

Outputs

tag         (1,1) Returned on initialize

See also AddAxes.


◆ AnimateVectors()

function AnimateVectors ( in  varargin)

Animate one or more time-varying vectors.


Form

fig = AnimateVectors( v1, color1, v2, color2 )


Inputs

v          (3,n)    Time-varying vector
color      (1,n)    Color of vector, i.e. 'r' or [1 0 0]

Outputs

fig         (1)     Handle to figure.

◆ Animator()

function Animator ( in  fig,
in  data,
in  background,
in  style,
in  markersize,
in  linewidth 
)

Animate a set of 2xN or 3xN matrices over N steps.

After initializing, use the "Animate" menu in the figure to play the animation. For example:

t = linspace(0,10,200);
r = [sin(t);cos(t);t/10];
Animator( [], r );

Form

[fh,ph,bh] = Animator( fig, data, background, style, markersize, linewidth )


Inputs (single data set)

fig              (1)   Figure handle for the plot. If empty, a new
figure is created.
data            (M,N)  Data to be animated M = 2 or 3. N = # samples.
background       (1)   Flag. Plot the trajectory as a background?
style            (:)   String indicating color, linestyle, marker
For example: 'r:x'. Must be in this order.
markersize       (1)   The marker size to use for the animated point
linewidth        (1)   The line width to use for the background line

Inputs (multiple data sets)

fig              (1)   Figure handle for the plot. If empty, a new
figure is created.
data             {K}   Cell array with K sets of data.
background      (1,K)  Array of K background flags.
style            {K}   Cell array of K style strings.
markersize       (K)   Array of K marker sizes
linewidth        (K)   Array of K line widths


NOTE: If a single property (background, style, etc.) is supplied when
there are multiple data sets, then that same property is used
for all data sets.

Outputs

fh               (1)   Figure handle
ph              (1,K)  Point handle
bh              (1,K)  Background handle
mh              (1,3)  Menu handles

◆ AnimQ()

function AnimQ ( in  q,
in  speed,
in  h,
in  propName,
in  propValue 
)

Animate the evolution of a quaternion over time.

Type AnimQ for a demo.


Form

h = AnimQ( q, speed, h, propName, propValue )   


Inputs

q              (4,:)  Time history of quaternion
speed           (1)   Speed factor (0 slow - 100 fast)
h               (1)   Handle of the figure to animate in (optional)
propName        {:}   Array of property names
ie, {'linewidth','linestyle'}
propValue       {:}   Array of property values
ie, {2,'--'}

Outputs

h              (1,1)  Figure handle

◆ Append()

function Append ( in  a1,
in  b1,
in  c1,
in  d1,
in  a2,
in  b2,
in  c2,
in  d2 
)

Appends two state space systems.

Appends two state space models assuming that they do not have
any inputs, states or outputs in common.

Form

[a, b, c, d] = Append( a1, b1, c1, d1, a2, b2, c2, d2 )



Inputs

a1                  Plant matrix
b1                  Input matrix
c1                  Measurement matrix
d1                  Input feedthrough matrix
a2                  Plant matrix
b2                  Input matrix
c2                  Measurement matrix
d2                  Input feedthrough matrix

Outputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix

◆ ArrayToLinspace()

function ArrayToLinspace ( in  x)

Converts an array a s function string.

[0 1 2 3 4 5] -> 'linspace(0,5,6)'

Type ArrayToLinspace for a demo


Form

s = ArrayToLinspace( x )


Inputs

x              (1,:)   Array

Outputs

s              (1,:)   String

◆ Arrow3D()

function Arrow3D ( in  r,
in  l,
in  g,
in  u,
in  c,
in  alpha,
in  hA 
)

Draws a 3D arrow into an existing figure.

You need to create a figure to draw it into such as: NewFig('3D Arrow');

Type Arrow3D for a demo showing cartesian axes.


Form

h = Arrow3D(r,l,g,u,c,alpha,hA)   % initialize
Arrow3D(h,g,u)                % update arrow's location


Inputs

r     (1,1) Radius
l     (1,1) Length
g     (3,1) Origin
u     (3,1) Unit vector
c     (1,3) Color [r g b], each element 0 to 1
alpha (1,1) Transparence 0 to 1
hA    (1,1) Handle to axies

Outputs

h     (1,1) Handle to patch object

◆ AssembleBlock()

function AssembleBlock ( in  x)

Assemble a block given the data structure.

x         .g       (1,1) Complete block model of class statespace
.gBase   (1,1) Base model (cannot be separated into SISO elements)
.sISOID  (1,1) ID of SISO element (not used here)
.sISO    (:)   .g          (1,1) Controller statespace representation
.name       (1,:) Controller name
.element    {:}   Controller type
.parameters {:}   Controller parameters
.inputs     {:}   Inputs
.outputs    {:}   Outputs  

You can add parallel systems, or add at the input and output. You can only do the latter two if x.g is not empty. It will add at the input or output if the input and output names of the SISO are the same and they match the systems input or output names.


Form

x = AssembleBlock( x )


Inputs

x      (1,1) Data structure defined above

Outputs

x      (1,1) Data structure defined above

◆ AssemblePlant()

function AssemblePlant ( in  gIn,
in  e,
in  in,
in  openLoop 
)

Assemble a plant given a model described by gIn.

If open loop the output is the output of the sensor. Otherwise it is the states of the plant.

gIn is a data structure with models for command, control, the plant and the sensors.

gIn.gCommand
gIn.gControl
gIn.gPlant
gIn.gSensor

where each field is a statespace class.

e is a data structure with indices giving connections between the blocks:

e.commandToControl 
(output of the command block to the input of the control block)
e.controlToPlant  
(output of the control block to the input of the plant block)
e.plantToSensor 
(output of the plant block to the input of the sensor block)
e.sensorToControl 
(output of the sensor block to the input of the control block)

where each field is a matrix that defines the connection between the input of the first and the output of the second. For example [1 1] means first output into first input.

See series (not Series) for more information about connections.


Form

g = AssemblePlant( gIn, e, in, openLoop )


Inputs

gIn       (:)   
.gCommand
.gControl
.gPlant
.gSensor
e         (.) Datastructure
.commandToControl
.controlToPlant
.plantToSensor
.sensorToControl
in        (1,:) 'noise', 'disturbance', 'command' 
openLoop  (1,1) If 1 generate the open loop plant

Outputs

gC        (1,1)  The complete statespace plant

◆ AssignColors()

function AssignColors ( in  n,
in  sat,
in  val 
)

Choose n colors from around the RGB color wheel.

Saturation: reducing the saturation lightens the colors while remaining on the same "spoke" of the color wheel. A saturation of 0 produces all grays.

Value: ratio between RGB components remains the same, but overall magnitude drops to make colors darker. ex. [1 0.85 0] and [0.684 0.581 0]


Form

colors = AssignColors( n, sat, val )


Inputs

n       (1,1)     Number of colors
sat     (1,1)     Saturation (from 0 to 1)
val     (1,1)     Value (from 0 to 1)

Outputs

colors  (n,3)     Matrix of RGB colors

See also hsv2rgb, ColorSpread


◆ AssignFHandle()

function AssignFHandle ( in  fName)

Assign either a string or function handle depending on the MATLAB version.

The function must exist as an independent file.

Form

f = AssignFHandle( fName )


Inputs

fName        (:)    String name of a function

Outputs

f            (:)    String name or function handle for versions above 5.2

◆ AtomicMass()

function AtomicMass ( in  atom,
in  units 
)

Outputs atomic mass in kg or amu.

Type AtomicMass for a demo and list of available atoms.


Form

m = AtomicMass( atom )


Inputs

atom          (1,:)  Atom name
units         (1,:)  'amu' or 'kg'

Outputs

m             (1,1)  Mass (kg or AMU)

◆ AttitudeCoordinates()

function AttitudeCoordinates ( in  varargin)

Draw attitude coordinates.

You can add these to any 3D plot.


Form

AttitudeCoordinates( varargin )


Inputs

varargin  {:} Parameter pairs
grid       - on/{off}
numbers    - {on}/off
radius     - default is 1
n          - default is 180
ticks      - {on}/off
axesHandle - {[]} or specify a handle

Outputs

None

◆ AU2M()

function AU2M ( in  angle,
in  u 
)

Convert an angle and a unit vector to a matrix.

The resulting matrix transforms from the unrotated frame to the
rotated frame


Type AU2M for a demo.

Form

m = AU2M( angle, u )


Inputs

angle         (1,1)   Angle
u             (3,1)   Unit vector

Outputs

m             (3,3)   Matrix

◆ AU2Q()

function AU2Q ( in  angle,
in  u 
)

Convert an angle and a unit vector to a quaternion.

Transforms from the unrotated to the rotated frame.


Form

q = AU2Q( angle, u )


Inputs

angle         (1,:)   Angle (rad)
u             (3,1)   Unit vector

Outputs

q             (4,:)   Quaternion from unrotated to rotated frame

◆ AxesCart()

function AxesCart ( in  xMin,
in  yMin,
in  zMin 
)

Draw axes on the current plot with X, Y, Z, text labels.

The axes are all red.


Form

AxesCart( xMin, yMin, zMin )


Inputs

xMin    (1,1)     Where you want the x-axis to start
yMin    (1,1)     Where you want the y-axis to start
zMin    (1,1)     Where you want the z-axis to start

Outputs

None

◆ Axis3D()

function Axis3D ( in  s)

Adjust 3D axes properties.

Axis3D is the same as Axis3D('equal')


Form

Axis3D( s )


Inputs

s                 String 'equal' is the only option available

Outputs

None

◆ AxisEqual()

function AxisEqual ( in  axisHandle,
in  minSize,
in  dim 
)

Equalize the axes with a minimum relative size for the smallest axis.


Form

AxisEqual( axisHandle, minSize, dim );


Inputs

axisHandle    (1,1)  Handle to the axis
minSize       (1,1)  Minimum size of smallest axis, expressed as a
percentage of the maximum axis size.
Optional. Default is 0.1.
dim           (1,1)  Dimension (2 or 3). Optional. Default is 3.

Outputs

none 

◆ BalReal()

function BalReal ( in  a,
in  b,
in  c,
in  d 
)

Compute the balanced realization of a, b, c, d.


Form

[a, b, c, d, t, g, err] = BalReal( a, b, c, d )


Inputs

a                   State matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix

Outputs

a                   State matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix
t                   Transformation matrix
g                   The observability and controllability grammiam
err                 Error

◆ BalRealG()

function BalRealG ( in  g)

Computes a balanced realization of g.

The same as BalReal except for a state space class.

Form

[g, t, gram, err] = BalRealG( g )


Inputs

g           (:)   Plant model of type statespace

Outputs

g           (:)   Augmented plant
t           (:)   Transformation matrix
gram        (:)   The observability and controllability grammiam
err         (1,1) Error

◆ BarPlot()

function BarPlot ( in  x,
in  y 
)

Creates a bar plot of x.

x(k) is assumed held constant from k to k+1. Plots on the current axes.

Type BarPlot for a demo.


Form

BarPlot( x, y )


Inputs

x              (1,n)    X-value
y              (1,n-1)  Y-value

Outputs

None

◆ BlockDiagramPlugIn()

function BlockDiagramPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a BlockDiagram GUI plug in.

Type BlockDiagramPlugIn for a demo.


Form

x = BlockDiagramPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ BodeGP()

function BodeGP ( in  g,
in  w 
)

Computes the phase using the Bode gain phase rule.

Computes the phase using the Bode gain phase rule where


phase = 90 d|g|/dw|db/20


This is only true for minimum phase systems

Form

p = BodeGP( g, w )


Inputs

g         (n,m)  Complex gain
w         (1,m)  Frequency Points

Outputs

p                Phase (deg)

◆ Box()

function Box ( in  x,
in  y,
in  z,
in  openFace 
)

Generate a box centered at the origin.

The open face is a character string:

-x, +x, -y, +y, -z, +z

Type Box for a demo.


Form

[v, f] = Box( x, y, z, openFace )


Inputs

x           (1,1)  x length
y           (1,1)  y length
z           (1,1)  z length
openFace    (1,2)  Which face is open (optional)

Outputs

v           ( 8,3) Vertices
f           (12,3) Faces

◆ BoxWithRoundedSection()

function BoxWithRoundedSection ( in  x,
in  y,
in  z 
)

Generate a box with a rounded section.

The rounded section is on the +z face. The axis of curvature is +y.

Type BoxWithRoundedSection for a demo.


Form

[v,f] = BoxWithRoundedSection(x,y,z)


Inputs

x (1,1) x dimension
y (1,1) y dimension
z (1,1) z dimension

Outputs

v   (:,3) Vertices
f   (:,3) Faces

◆ BuildConstant()

function BuildConstant ( in  name)

Build the constant database.

You can add to this function to build your own constant databases. It saves the database as sCTConstants.

save sCTConstants constName constNameNoSpace value units

Form

BuildConstant( name )


Inputs

name            (1,:)  Name of the database

Outputs

None

◆ C2DelZOH()

function C2DelZOH ( in  a,
in  b,
in  T 
)

Create a discrete time systems using the delta operator.

Given
.
x = ax + bu


Find f and g where


x(k+1) = x + fx(k) + gu(k)

Form

[f, g] = C2DelZOH( a, b, T )


Inputs

a            (n,n)  Continuous plant matrix
b            (n,m)  Input matrix
T            (1,1)  Time step

Outputs

f            (n,n)  Discrete plant matrix
g            (n,m)  Discrete input matrix

References: Van Loan, C.F., Computing Integrals Involving the Matrix Exponential, IEEE Transactions on Automatic Control Vol. AC-23, No. 3, June 1978, pp. 395-404.

Middleton, R.H. and G.C. Goodwin, Digital Control and
Estimation: A Unified Approach, Prentice-Hall, 1986

◆ C2DFOH()

function C2DFOH ( in  a,
in  b,
in  T 
)

Create a discrete time system using a first order hold.

Create a discrete time system from a continuous system
assuming a first-order-hold at the input.


Given
.
x = ax + bu

Form

[f, g] = C2DFOH( a, b, T )


Inputs

a            (n,n)  Continuous plant matrix
b            (n,m)  Input matrix
T            (1,1)  Time step

Outputs

f            (n,n)  Discrete plant matrix
g            (n,m)  Discrete input matrix

◆ C2DPulse()

function C2DPulse ( in  a,
in  b,
in  T,
in  tau 
)

Create a discrete time system assuming a pulse at the input.

Create a discrete time system from a continuous system
assuming a pulse at the input.


Given
.
x = ax + bu


Find f and g where


x(k+1) = fx(k) + gu(k)

Form

[f, g] = C2DPulse( a, b, T, tau )


Inputs

a            (n,n)  Continuous plant matrix
b            (n,m)  Input matrix
T            (1,1)  Time step

Outputs

f            (n,n)  Discrete plant matrix
g            (n,m)  Discrete input matrix

References: Van Loan, C.F., Computing Integrals Involving the Matrix

Exponential, IEEE Transactions on Automatic Control Vol. AC-23, No. 3, June 1978, pp. 395-404.


◆ C2DZOH()

function C2DZOH ( in  a,
in  b,
in  T 
)

Create a discrete time system using a zero order hold.

Create a discrete time system from a continuous system
assuming a zero-order-hold at the input.


Given
.
x = ax + bu


Find f and g where


x(k+1) = fx(k) + gu(k)

Form

[f, g] = C2DZOH( a, b, T )


Inputs

a            (n,n)  Continuous plant matrix
b            (n,m)  Input matrix
T            (1,1)  Time step

Outputs

f            (n,n)  Discrete plant matrix
g            (n,m)  Discrete input matrix

References: Van Loan, C.F., Computing Integrals Involving the Matrix Exponential, IEEE Transactions on Automatic Control Vol. AC-23, No. 3, June 1978, pp. 395-404.


◆ C2DZOHWD()

function C2DZOHWD ( in  a,
in  b,
in  c,
in  T,
in  Td 
)

Create a discrete time system using a zero order hold and delay.

Create a discrete time system from a continuous system
assuming a zero-order-hold at the input with a delay.


Given
.
x = ax + bu
y = cx


Find f and g where


x(k+1) = fx(k) + gu(k)
y = cx(k) + du(k)


The delay is defined as
Td = l*T - m*T where l is always the least integer
number of sampling periods greater than the delay.

Form

[f, g, c, d, l, m] = C2DZOHWD( a, b, c, T, Td )


Inputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix
T                   Time step
Td                  The delay

Outputs

f                   Discrete plant matrix
g                   Discrete input matrix
c                   Output matrix
d                   Feedthrough matrix
l                   Number of integral period delays
m                   Fractional delay

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control

of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, pp. 56-61.


◆ CameraControls()

function CameraControls ( in  varargin)

This function creates a GUI for manipulating the camera view.

Initialize by supplying an axis handle. If no input is provided it will point to the current axis (gca).

This GUI does not provide direct control over the camera target. Set the camera target of axes "h" to vector "v" with this command:

set(h,'cameratarget',v)

Move in/out changes the distance from the camera to the target. Zoom in/out changes the view angle of the camera. Adjust azimuth and elevation to change the orientation of the camera

while keeping the distance constant.

The azimuth and elevation angles are defined in a local xyz coordinate frame.

x: along the direction of the camera target vector. 
y: cross product of z and x, completes right-handed system
z: cross product of x and the supplied forward vector

Note that the "forward" vector is not an axis property, and so it must be supplied directly to the CameraControls GUI.


USAGE:

% Initialize and use current axes (gca)
tag = CameraControls;


% Initialize with specified axes
tag = CameraControls( axisHandle );    


% Set the forward vector
CameraControls( 'set forward vector', tag, forwardVector );


% Update the view
CameraControls( 'update', tag );


% Update the view with a new forward vector
CameraControls( 'update', tag, forwardVector );    


Inputs

axisHandle      (1,1)   Handle to the axes for controlling the camera

Outputs

tag             (1,:)   Tag to the GUI.

See also: AnimationGUI


◆ Cart2Sph()

function Cart2Sph ( in  x,
in  y,
in  z 
)

Converts cartesian coordinates to spherical.


Form

[r, theta, phi] = Cart2Sph( x, y, z )


Inputs

x                     (:,:)  Either x or [x;y;z]
y                     (:)    y
z                     (:)    z

Outputs

r                     (:,:)  r or [r;theta;phi] (r is vector magnitude)
theta                 (:)    theta (angle in xy-plane)
phi                   (:)    phi (angle measured from z axis to xy plane)

◆ CButter()

function CButter ( in  n,
in  wC,
in  tSamp,
in  sType 
)

Create a continuous Butterworth Filter.

Build a continuous Butterworth Filter with output of the form

dx/dt = ax + bu y = cx + du

If no outputs are specified it will plot the frequency response 

Form

[a, b, c, d] = CButter( n, wC, tSamp, sType )


Inputs

n             (1,1) Order
wC            (1,1) Cutoff
tSamp         (1,1) Sampling frequency
sType         (1,:) State equation type ('Delta' or 'Z')

Outputs

a                   State transition matrix
b                   Input matrix
c                   Measurement matrix
d                   Feedthrough matrix

◆ CCVModel()

function CCVModel ( in  q)

Generate CCV (control configured vehicle) aircraft model.

This is useful for trying out the control functions


Type CCVModel for a demo.

Form

x = CCVModel( q )


Inputs

q          (1,:)    String describing the type of data
Use 'catalog' to print list of supported types

Outputs

x                      The properties

Reference: Stevens, B.L., Lewis, F.L. , Aircraft Control and Simulation, John Wiley & Sons, 1992, pp. 354-358.


See also @statespace/statespace.m, EigEval, SVPlot, Step


◆ CDKF()

function CDKF ( in  d,
in  fName,
in  hName 
)

Continuous discrete iterated extended Kalman Filter.

The state and covariance matrices are numerically integrated. The model is of the form:

dx/dt = f(x,t,u)
y = h(x,t,u)


F(x,t,u) = df/dx
H(x,t)   = dh/dx

x is the estimated state. Name is a function of the form:

[xDot, d.fData] = fName( x, t, d.fData )

hName is a function of the form:

[z, dhdx] = hName( x, t, d.hData, d.meas.k )

If dhdx is empty, CDKF will linearize hName about x and t. k are the indices to the measurements for which there is data.


Form

d = CDKF( d, fName, hName )


Inputs

d             (:)     Data structure
.time             Time or jD
.year
.month                             
.day                             
.hour                             
.minute                             
.second
.timeLast         Time of last call
.secFromStart     Seconds from start
.x                State
.p                Covariance
.q                Plant noise matrix
.k                Gain matrix
.r                Measurement noise matrix
.nIterations      Number of iterations
.meas             Measurements
.z           New measurement(s)
.k           Indices of new measurement(s)
.fData            f function data
(user defined)
.hData            h function data
(user defined)


fName         (1,:)   Dynamics function name
hName         (1,:)   Measurement function name

Outputs

d             (:)     Data structure

References: Gelb, A. Ed., Applied Optimal Estimation, MIT Press. p.188. Table 6.1-1. Also, pp. 190-191.


◆ Cell2DToStruct()

function Cell2DToStruct ( in  y,
in  m 
)

Convert a structure into a cell array where columns of the array.

include both values and fieldnames. For example, the cell

a 1 b c 2 b d 3

Becomes

x.a = 1 x.b.c = 2; x.b.d = 3;

The companion array m is

1 0 0 1 1 0

1 1 0

Where a 1 indicates that the cell is a field name. Where a 1 indicates that the cell is a field name.


Form

x = Cell2DToStruct( y, m )


Inputs

y        (:)    Cell Array

Outputs

x        (:)    Structure

◆ CellToMat()

function CellToMat ( in  c)

Converts a cell array to a matrix.


Form

x = CellToMat( c )


Inputs

c           {}    One dimensional cell array of strings

Outputs

x         (:)   Matrix

◆ CenterFigure()

function CenterFigure ( in  width,
in  height 
)

Find a position array that centers a figure.


Form

position = CenterFigure( width, height )


Inputs

width         (1,1)   Figure width
height        (1,1)   Figure height

Outputs

position      (1,4)   [left bottom width height]     

◆ Centroid()

function Centroid ( in  v)

Compute a centroid from a set of vertices.


Form

c = Centroid( v )


Inputs

v             (3,:)   Polygon vertices

Outputs

c             (3,1)   Centroid

◆ CGram()

function CGram ( in  a,
in  b 
)

Compute the controllability gramian for a continuous time system.


Form

[p, err] = CGram( a, b )


Inputs

a                   State matrix
b                   Input matrix

Outputs

p                   Controllability gramian
err                 Norm of the error

◆ ChangePath()

function ChangePath ( in  newPath)

Change the path.


Form

currentPath = ChangePath( newPath )


Inputs

newPath       (1,:)   New path

Outputs

currentPath   (1,:)   Current path (before the change);     

◆ CInputs()

function CInputs ( in  t,
in  tStart,
in  d,
in  type 
)

Generates different control inputs.

d is the data 
pulse doublet:  d.init, d.dT, d.magnitude
step:           d.init, d.magnitude
ramp:           d.init, d.slope


d.init      is the initial u
d.dT        is the duration of the pulse
d.magnitude is the magnitude of the pulse
d.slope     is the slope

Form

u = CInputs( t, tStart, d, type )


Inputs

t           (1,1)  Time
tStart      (1,1)  Time to start
d           (:)    Data
type        (1,:)  Type 'pulse', 'doublet', 'ramp', 'step'

Outputs

u           (1,1)  Output

◆ Circle()

function Circle ( in  r,
in  xc,
in  yc,
in  n 
)

Compute x y data for a 2-D Circle.


Form

[x,y] = Circle(r,xc,yc,n)


Inputs

r                 (1)     radius
xc                (1)     x- center
yc                (1)     y- center
n                 (1)     number of points around circle

Outputs

x                (1,n)    x-data 
y                (1,n)    y-data 

◆ CLoopS()

function CLoopS ( in  a,
in  b,
in  c,
in  ac,
in  bc,
in  cc,
in  dc 
)

Creates a closed loop system.

Creates a closed loop system given the plant [a,b,c] and the
controller [ac,bc,cc,dc]. Every output of the controller has
a corresponding input in the plant and yc(i) = u(i), etc.

Form

[at, bt, ct, dt] = CLoopS( a, b, c, ac, bc, cc, dc )
[at, bt, ct, dt] = CLoopS( a, b, c, k )


Inputs

a             (2n,2n)  Plant matrix
b             (2n, n)  Input matrix
c             ( n,2n)  Output matrix
ac            (2n,2n)  Controller plant matrix
bc            (2n, n)  Controller input matrix
cc            ( n,2n)  Controller output matrix
dc            ( n, n)  Controller feedthrough matrix


or


k             ( n, n)  Gain matrix

Outputs

at            (2n,2n)  System plant matrix
bt            (2n, n)  System input matrix
ct            ( n,2n)  System output matrix
dt            ( n,2n)  System feedthrough matrix

◆ CloseFigure()

function CloseFigure ( in  h)

Close a figure.


Form

CloseFigure( h )


Inputs

h           (1,1) Handle

Outputs

none

◆ CloseIfHandle()

function CloseIfHandle ( in  h)

Close h if it is a handle to a figure.


Form

CloseIfHandle( h )


Inputs

h       (:)   Handles

Outputs

None 

◆ CloseMatFile()

function CloseMatFile ( in  kOpenPre)

Closes every file not listed in kOpenPre.


Form

CloseMatFile( kOpenPre )


Inputs

kOpenPre            (1,:)  List of file ids

Outputs

None

◆ CloseUIElement()

function CloseUIElement ( in  h)

Close a UIElement.


Form

CloseUIElement( h )


Inputs

h          (:)   Handle

Outputs

none

◆ CLPoles()

function CLPoles ( in  a,
in  b,
in  c,
in  f,
in  g,
in  h,
in  k 
)

Computes the closed loop poles.

Computes the closed loop poles for a control system


z =  f*z - g*y
u  =  h*z - k*y


The plant is assumed to be in the form


x = a*x + b*u
y  = c*x


Automatically reduces the order of the system.

Form

z = CLPoles( a, b, c, f, g, h, k )


Inputs

[a,b,c]         Plant matrices
[f,g,h,k]   Controller matrices

Outputs

z               Closed loop poles

◆ ColorMapGrayScale()

function ColorMapGrayScale ( )

Generates a gray scale colormap with 256 entries.

Note: colormap('gray') has only 64 entries.


Form

ColorMapGrayScale


Inputs

None

Outputs

None

◆ ColorSpread()

function ColorSpread ( in  n,
in  map 
)

Produce a set of 3-element RGB colors that spread across the colormap.

If a map is not specified it will grab the default figure color map.


Form

colors = ColorSpread( n, map )


Inputs

n             (1,1)    Number of colors to produce
map           (:,3)    Colormap, optional

Outputs

colors        (n,3)    n rows of colors

See also AssignColors


◆ ColumnSizeCellArray()

function ColumnSizeCellArray ( in  m,
in  f 
)

Outputs the size of each column of a cell array.

Elements of m can be strings or scalars.


Form

s = ColumnSizeCellArray( m, f )


Inputs

m               (n,m)  Cell array
f               (1,1)  Width of number fields

Outputs

f               (1,m)  Maximum width of each column

◆ CompE()

function CompE ( in  x,
in  sType,
in  dT 
)

Create a SISO compensator using a variety of compensator elements.

Each
element of d is a data structure which contains the parameters of the
particular compensator.


Element Type                Underlying Function
--------------------        -------------------
'butterworth filter'        CButter
'delay'                     Delay
'general second order'      Gen2nd
'integral'                  Integral
'lead-lag'                  LeadLag
'notch'                     Notch
'pilot'                     Pilot
'pulsewidth modulator'      PWM
'shaping filter'            ShapeFlt
'washout'                   ND2SS( [1 0], [1 w] );
'zero order hold'           ZOH

Form

g = CompE( x, sType, dT )


Inputs

x           (n)   Compensator element data structure
.type
.name
.... (different for each element type)
sType       (1,:) State space type, 'delta', 'bilinear', 'zoh', 'forward', 'backward'
dT          (1,1) Time step

Outputs

g           (:)   Compensator

◆ ComputeGainsPlugIn()

function ComputeGainsPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a detection filter gains GUI plug in used by DetectionFilterBuilder.


Form

x = ComputeGainsPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ Cone()

function Cone ( in  p,
in  u,
in  halfAngle,
in  l,
in  n 
)

Compute the vertices for a cone.

The cone emanates from p and points in direction u. If no outputs are specified the cone will be drawn in a new figure.

Type Cone for a demo.


Form

[v, f] = Cone( p, u, halfAngle, l, n)


Inputs

p            (3,1) Location of apex
u            (3,1) Cone axis unit vector
halfAngle    (1,1) Cone half angle (rad)
l            (1,1) Length of cone
n            (1,1) Number of divisions

Outputs

v            (:,3) Vertices
f            (:,3) Faces

◆ Constant()

function Constant ( in  q,
in  gUICode 
)

Outputs the value of a constant or opens a GUI for searching.

q must be an exact match. Case and spaces have no effect. To search for a string (without using the GUI) type

Constant( searchString, 'find' )

Loads either sCTConstants.mat or, if not found, ACTConstants.mat.


Form

[x, u] = Constant( q, gUICode )


Inputs

q               (1,:)  String describing the constant
gUICode         (1,:)  GUI code

Outputs

x               (1,1)  The value
u               (1,:)  Units (if applicable)

Referenced by CreateGUI().

◆ ControlDesignGUI()

function ControlDesignGUI ( in  action,
in  modifier,
in  u 
)

Design control systems using a GUI.

This GUI maintains a data structure for the system that is modeled. The data structure is

h.x .g       (1,1) Complete plant model of class statespace
.gBase   (1,1) Base model (cannot be separated into SISO elements)
.sISO    (:)   .g          (:)   Controller statespace representation
.type       {:}   Controller type
.parameters {:}   Controller parameters
.connection (1,1) 'base input', 'base output', 'parallel'
.baseInput  (1,1) Base input if in series into a base input
.baseOutput (1,1) Base output if in series from a base output
.outputName (1,:) Output name
.inputName  (1,:) Input name

Typing ControlDesignGUI is the same as ControlDesignGUI( 'initialize' )


Form

x = ControlDesignGUI( action, modifier, u )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifier    (1,:)  Logo tiff if action is 'initialize' or GUI tag if not.
u           (:)    Input when 'set data' is the action

Outputs

x           (:)    Output is dependent on the action. On initialization
returns the window tag.

◆ ConvertFortranFormatToC()

function ConvertFortranFormatToC ( in  f)

Convert Fortran formats to C.

Specifically A, I, D, E, F are converted.


Form

[c, len, type] = ConvertFortranFormatToC( f )


Inputs

f               (1,:) String with FORTRAN formats
fileName        (1,:) fileName

Outputs

c               {}     Cell array of formats
len             (:)    Length of each element
type            {:}    'string' or 'number'

◆ ConvertOBJFileColorToMatlab()

function ConvertOBJFileColorToMatlab ( in  m)

Converts the Wavefront OBJ color format to MATLAB.

Edge color is set equal to face color


Form

d = ConvertOBJFileColorToMatlab( m )


Inputs

m             (.)  Material file data structure
.Kd    (1,3) Diffuse reflectivity
.Ks    (1,3) Specular reflectivity
.Ka    (1,3) Ambient reflectivity
.Ns    (1,3) Specular exponent
.illum (1,3) Illumination model (not used)
.d     (1,1) Transparency

Outputs

d             (.)  Matlab color
.faceColor                (1,3) Color of faces
.edgeColor                (1,3) Color of edges
.diffuseStrength          (1,1)
.specularStrength         (1,1)
.ambientStrength          (1,1)
.specularExponent         (1,1)
.specularColorReflectance (1,1)
.faceAlpha                (1,1) Alpha channel

◆ CoordinateFrameFromUV()

function CoordinateFrameFromUV ( in  u)

Computes a transformation matrix from the frame.

u is defined n a frame in which u is the z-axis and the other axes form an orthogonal set.


Form

b = CoordinateFrameFromUV( u )


Inputs

u              (3,1)  Unit vector

Outputs

b              (3,3)  Transformation matrix

◆ Coordinates()

function Coordinates ( in  m)

Creates a figure with x,y,z coordinates at the origin.

The figure has a black background and white axes.


Form

h = Coordinates( m )


Inputs

m             (1)     Magnitude of each axis

Outputs

h             (1)     Figure handle

◆ CPGas()

function CPGas ( in  t,
in  gas 
)

Thermal capacity for a gas as a function of temperature.

Type CPGas for a demo with all gases. CO2 is the default.


Form

cP = CPGas( t, gas )


Inputs

t    (1,:)  Temperature (deg-K)
gas  (1,:)  Gas 'Ar', 'He', 'CO2', 'N2', 'Air'

Outputs

cP   (1,:)  Thermal capacity (J/kg-deg-K)

◆ CPIAdjust()

function CPIAdjust ( in  cC,
in  yearC,
in  yearN 
)

Consumer Price Index adjustment.

Type CPIAdjust for a demo which will also plot CPI versus year.

Form

cP = CPIAdjust( cC, yearC, yearN )


Inputs

cC    (:,:)   Price at year cC to adjust
yearC (1,1)   Year for cC
yearN (1,1)   Year for which to compute cC

Outputs

cP     (:,:)   Adjusted prices

◆ CreateHTMLTable()

function CreateHTMLTable ( in  x,
in  fileName,
in  fString,
in  title 
)

Creates an HTML table from x.

x may be a two dimensional cell array or a matrix. If fileName is a string, it will open a file with the name fileName.html and write the matrix into the file. If instead you enter a file id it will write to the already open file. fString applies only to numbers. The default for fString is %12.4e.


Form

CreateHTMLTable( x, fileName, fString, title )


or


CreateHTMLTable( x, fId, fString, title )


Inputs

x               {:,:} or (:,:) Cell array or matrix
fileName or fId (:)            File name or file id
fString         (1,:)          Number format string
title           (1,:)          Table title

Outputs

None

◆ CreateLatexTable()

function CreateLatexTable ( in  x,
in  fileName,
in  fString,
in  title 
)

Creates a LaTeX table from x.

x may be a two dimensional cell array or a matrix. If fileName is a string, it will open a file with the name fileName.tex and write the matrix into the file. If instead you enter a file id it will write to the already open file. fString applies only to numbers. The default for fString is %12.4e.


Form

CreateLatexTable( x, fileName, fString, title )
CreateLatexTable( x, fId, fString, title )


Inputs

x               {:,:} or (:,:) Cell array or matrix
fileName or fId (:)            File name or file id
fString         (1,:)          Number format string
title           (1,:)          Table title

Outputs

None

◆ CreateTable()

function CreateTable ( in  x,
in  fileName,
in  fString,
in  sep 
)

Creates a table from x for displaying to the command line.

x may be a two dimensional cell array or a matrix.
Based on CreateLatexTable and CreateHTMLTable but without the tags.

Forms: CreateTable( x ) CreateTable( x, fileName, fString ) CreateTable( x, fId, fString, sep )


◆ CToD()

function CToD ( in  g,
in  dT,
in  sType 
)

Create a discrete time compensator from a continuous time compensator.

sType 'delta' 'zoh',

Form

g = CToD( g, dT, sType )


Inputs

g           (n)   Compensator element data structure
.type
dT          (1,1) Sampling time                  ...
sType       (1,:) Discrete time type

Outputs

g           (:)   Compensator

◆ CWPAModel()

function CWPAModel ( in  dT)

Continuous Wiener process acceleration (CWPA) model.

This is a 2 dimensional model planar movement model that includes acceleration states.

This is a discrete time model.

The state is [x y xDot yDot xDoubleDot yDoubleDot]'.

Type CWPAModel for an example with dT = 1.


Form

[a, h, q] = CWPAModel( dT )


Inputs

dT            (1,1) Time step (sec)

Outputs

a             (6,6) State transition matrix    
h             (2,6) Measurement matrix    
q             (6,6) Plant noise covariance matrix    

◆ CylinderWithHemisphere()

function CylinderWithHemisphere ( in  r,
in  h 
)

Generates a cylinder with a hemisphere on one end instead of a flat disk.


Form

[v, f] = CylinderWithHemisphere( r, h )


Inputs

r   (1,1)   Radius of cylinder
h   (1,1)   Height of cylinder

Outputs

v   (:,3) Vertices
f   (:,3) Faces

◆ Database()

function Database ( in  q,
in  gUICode 
)

GUI to output the value of a constant.

q must be an exact match.

Case and spaces have no effect. To search for a string (without using the GUI) type Database( searchString, 'find' ). You must initialize the database before using it. The first time you call Database type:

Database( 'fullFileName' )

or

Database

The second option will bring up a file selection dialog box. The database expects a tab separated text file of the form:

name value units reference

For a demonstration type

Database('Sample.db')

Once you open a database you cannot open another one with the command

Database(fileName)

since after opening all inputs are assumed to be database searches. Use clear to reset the function for a new database.

This function works the same as Constant.


Form

[x, u] = Database( q, gUICode )


Inputs

q               (1,:)  String describing the constant
gUICode         (1,:)  GUI code

Outputs

x               (1,1)  The value
u               (1,:)  Units (if applicable)

◆ Date2DN()

function Date2DN ( in  datetime)

Compute the day number from the date.

Uses the format from clock.

If no inputs are given it will compute the day number for the instant of the function call.


Form

dn = Date2DN( datetime )


Inputs

datetime     (1,6) [year month day hour minute seconds]

Outputs

dn           (1,1) Day number

References: Montenbruck, O., T.Pfleger, Astronomy on the Personal Computer, Springer-Verlag, Berlin, 1991, p. 12.


◆ Date2FY()

function Date2FY ( in  datetime)

Computes the fractional year from the date.


Form

fy = Date2FY( datetime )


Inputs

datetime   (1,6) [year month day hour minute seconds]

Outputs

fy         (1,1) Fractional year

◆ Date2JD()

function Date2JD ( in  datetime)

Compute the Julian Date from the date.

Uses the format from clock. If no inputs are given, it will compute the Julian date for the instant of the function call. Only works for dates after 1600. You may omit the last three numbers (hour minute seconds) in the array. The date is in Greenwich Mean Time


Form

jd = Date2JD( datetime )


Inputs

datetime      (1,6) [year month day hour minute seconds]
or the datetime data structure.
.year
.month                             
.day                             
.hour                             
.minute                             
.second

Outputs

jd            (1,1) Julian date

References: Montenbruck, O., T. Pfleger, Astronomy on the Personal Computer, Springer-Verlag, Berlin, 1991, p. 12.


◆ DateChanged()

function DateChanged ( in  date,
in  directory 
)

Find a list of files in the directory who have been modified after.


Form

d = DateChanged( date, directory )


Inputs

date          (1,:)   Date to compare in string format
directory     (1,:)   Directory to check

Outputs

d             {:}     Files with modification dates after date  

◆ DateStringToJD()

function DateStringToJD ( in  s)

Convert a date string to Julian date.

The date string must be in the form 4/20/2000 00:00:00 or 4/20/2000

Type DateStringToJD for a demo


Form

jD = DateStringToJD( s )


Inputs

s             (1,:)   String 'mm/dd/yyyy hh:mm:ss' or 'mm/dd/yyyy'
or 'mm/dd/yyyy hh:mm'

Outputs

jD            (1,1)   Julian Date   

◆ DBalReal()

function DBalReal ( in  a,
in  b,
in  c,
in  d 
)

Compute a balanced realization for discrete time systems.

Compute the balanced realization of a, b, c, d for discrete time systems.


Form

[a, b, c, d, t, g, err] = DBalReal( a, b, c, d )


Inputs

a                   State matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix

Outputs

a                   State matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix
t                   Transformation matrix
g                   The observability and controllability grammiam
err                 Error

◆ DBode()

function DBode ( in  a,
in  b,
in  c,
in  d,
in  iy,
in  iu,
in  w,
in  dT 
)

Generates a Bode plot for a discrete time system.

Generates a Bode plot for a discrete time system from iu to iy.


x(k+1) = ax(k) + bu(k)
y(k) = cx(k) + du(k)

Form

DBode( a, b, c, d, iy, iu, w, dT )


Inputs

a   (n,n    State transition matrix
b       (n,m)   Input matrix
c       (p,n)   Measurement matrix
d       (p,m)   Input feedthrough matrix
iy  (1,1) Output channel
iu  (1,1) Input channel
w   (1,:) Plot frequency vector (rad/sec)
dT  (1,1) Time step         

Outputs

none     

◆ DCGain()

function DCGain ( in  a,
in  b,
in  c,
in  d,
in  sType 
)

Computes the DC gain of a discrete time state space system.


Form

g = DCGain( a, b, c, d, sType )


Inputs

a                   Discrete plant matrix
b                   Discrete input matrix
c                   Discrete output matrix
d                   Discrete feedthrough matrix
sType               State equation type ('Delta' or 'Z')

Outputs

g                   Gain

◆ DCGram()

function DCGram ( in  a,
in  b 
)

Compute the controllability gramian for a discrete time system.


Form

[p, err] = DCGram( a, b )



Inputs

a                   State matrix
b                   Input matrix

Outputs

p                   Solution
err                 Norm of the error

◆ DeBlankAll()

function DeBlankAll ( in  s)

Delete all blanks.

Including spaces, new lines, carriage returns, tabs, vertical tabs, and formfeeds.


Form

s = DeBlankAll( s )


Inputs

s      (1,:)   Character string

Outputs

s      (1,:)   Character string

◆ DeBlankLT()

function DeBlankLT ( in  s)

Delete leading and trailing blanks.


Form

s = DeBlankLT( s )


Inputs

s      (1,:)   Character string or cell array

Outputs

s      (1,:)   Character string or cell array

◆ DebugLog()

function DebugLog ( in  msg,
in  fullPath 
)

Display a message to help debugging.

Use this function instead of adding disp() statements or leaving out
semicolons. The full path option will print a complete backtrace.

Form

DebugLog( msg, fullPath )


Inputs

msg          (.)     Any message
fullPath     (1,1)   If entered, print the full backtrace

Outputs

None

◆ Deg2DMS()

function Deg2DMS ( in  a)

Convert degrees to degrees, minutes and seconds.


Form

[d, m, s] = Deg2DMS( a )


Inputs

a              (1,:)  Angle in degrees

Outputs

d              (1,:)  Degrees or [d;m;s]
m              (1,:)  Minutes
s              (1,:)  Seconds

References: The 1993 Astronomical Almanac, p. C24.


◆ Deg2HMS()

function Deg2HMS ( in  a)

Convert radians to hours, minutes and seconds.


Form

[h, m, s] = Deg2HMS( a )


Inputs

a              (1,:)  Angle in degrees

Outputs

h              (1,:)  hours or [h;m;s]
m              (1,:)  minutes
s              (1,:)  seconds

References: The 1993 Astronomical Almanac, p. C24.


◆ Delay()

function Delay ( in  T,
in  n 
)

Create a model of a delay using Pade approximants for exp(-sT).


Form

[a,b,c,d] = Delay( T, n )
[num,den] = Delay( T, n )


Inputs

T            (1,1)  Delay
n            (1,1)  Number of terms

Outputs

a or num            Numerator polynomial or plant matrix
b or den            Denominator polynomial or input matrix
c                   Measurement matrix
d                   Feedthrough matrix

◆ DeleteCell()

function DeleteCell ( in  c,
in  k 
)

Delete a cell element of a one dimensional cell array.

If k is a logical array, the cells that will be deleted are the ones with true values, i.e. c = c(~k)


Form

c = DeleteCell( c, k )


Inputs

c        {}  Cell array
k        (:) Array of elements, or logical array

Outputs

c        {}  Cell array

◆ DeleteFromList()

function DeleteFromList ( in  h)

Delete the selected item from a list.


Form

DeleteFromList( h )


Inputs

h             (1,1)   Handle to list

Outputs

None    

◆ DeleteIfHandle()

function DeleteIfHandle ( in  h)

Close h if it is a handle.


Form

DeleteIfHandle( h )


Inputs

h       (:)   Handles

Outputs

None 

◆ DeleteSuffix()

function DeleteSuffix ( in  x)

Deletes the .xxx part of a name.


Form

x = DeleteSuffix( x )


Inputs

x           {}       String or cell array of strings

Outputs

x           {}       String

◆ DeltaQToRate()

function DeltaQToRate ( in  q1,
in  q2,
in  dT 
)

Angular rate from small quaternion changes.

This assumes small dT and small changes in q.

Type DeltaQToRate for a test with a random quaternion.


Form

omega = DeltaQToRate( q1, q2, dT )


Inputs

q1    (4,1) Old quaternion
q2    (4,1) New quaternion
dT    (1,1) Time step (s)

Outputs

omega   (3,1) Angular rate (rad/s)

◆ DeltaT()

function DeltaT ( in  jd)

Computes the difference between UT1 and TT based on the Julian date.

This model is based on observations up through 1993 and after that is a linear extrapolation. The equation is UT1 = TT - DT.

If you type DeltaT it will compute dt for the current date and time.


Form

dt = DeltaT( jd )


Inputs

jd           (1,1) Julian date

Outputs

dt           (1,1) Time difference

References: U.S. Naval Observatory, MICA, U.S. Naval Observatory Washington, D.C., p. C-1.


◆ DigitalFilter()

function DigitalFilter ( in  uNew,
in  nN,
in  dN,
in  xN,
in  uN 
)

Implement a digital filter.

Type DigitalFilter for a demo.

Form

[xNew, xN, uN] = DigitalFilter( uNew, nN, dN, xN, uN )


Inputs

uNew                   New input
nN           (1,n)     Numerator polynomial
dN           (1,n)     Denominator polynomial
uN           (1,n)     Input storage
xN           (1,n)     Output storage

Outputs

xNew                   New output
uN           (1,n)     Input storage
xN           (1,n)     Output storage

◆ DirToCell()

function DirToCell ( in  path,
in  y 
)

Converts a directory list into a cell array.

The second argument can be used to filter the names found in the list of files.


Form

c = DirToCell( path )


Inputs

path     {}     Path to the directory to be searched
y        {}     Output only those files that have y in them

Outputs

c        (:)   Cell array

◆ Disk()

function Disk ( in  r,
in  n,
in  z 
)

Generate a disk.

For correct lighting points must be entered counterclockwise. Type Disk for a demo.


Form

[v, f] = Disk( r, n, z )


Inputs

r           (1,1) Radius
n           (1,1) Number of points
z           (1,1) Height

Outputs

v           (4,3) Vertices
f           (4,3) Faces

◆ DiskWithHole()

function DiskWithHole ( in  rI,
in  rO,
in  n,
in  z 
)

Draw a disk.

For correct lighting points must be entered counterclockwise.

Type Disk for a demo.


Form

[v, f] = DiskWithHole( rI, rO, n, z )


Inputs

r           (1,1) Radius
n           (1,1) Number of points
z           (1,1) z

Outputs

v           (4,3) Vertices
f           (4,3) Faces

◆ DispG()

function DispG ( in  action,
in  modifier 
)

Display a statespace system using vertical bar charts.

Has a built-in demo for the L1011.


DispG is the same as DispG('initialize');

Form

DispG( action, modifier )


Inputs

g        (:)     Plant object of type statespace
hAxes    (1,1)   Figure handle

Outputs

hPlot    (1,1)   Handle to the plot

◆ DisplayLatexTable()

function DisplayLatexTable ( in  s)

Displays a LaTeX table.


Form

DisplayLatexTable( s )


Inputs

s               {:,:} Cell array to be displayed

Outputs

None

◆ DispWithTitle()

function DispWithTitle ( in  x,
in  t 
)

Display a variable with a title.

x can be any MATLAB variable. If the title is left out, the variable name will be displayed via inputname. The variable is displayed using disp.

Type DispWithTitle for a demo.


Forms: DispWithTitle( x, t ) DispWithTitle( x )



Inputs

x   :     Variable
t   (1,:) Title

Outputs

None

◆ DistanceLabel()

function DistanceLabel ( in  d)

Rescales distances.

Generates a distance label given the maximum value of d and rescales d.


Form

[d, c, u] = DistanceLabel( d )


Inputs

d   (1,:)   Distance (m)

Outputs

d   (1,:)   Distance ()
c   (1,:)   Label (mm, cm, m, km, au, light year)
u   (1,:)   Units of distance

◆ DMS2Deg()

function DMS2Deg ( in  d,
in  m,
in  s 
)

Convert degrees, minutes and seconds to radians.


Form

a = DMS2Deg( d, m, s )
a = DMS2Deg( [d;m;s] )


Inputs

d            (1,:)    Degrees or [d;m;s]
m            (1,:)    Minutes
s            (1,:)    Seconds

Outputs

a            (1,:)    Angle in degrees

References: The 1993 Astronomical Almanac, p. C24.


◆ DMS2Rad()

function DMS2Rad ( in  d,
in  m,
in  s 
)

Convert degrees, minutes and seconds to radians.

Inputs can be d,m,s, [d;m;s] or d:m:s or d:m or d.

Type DMS2Rad for a demo

Form

rad = DMS2Rad( d, m, s )
rad = DMS2Rad( [d;m;s] )
rad = DMS2Rad( d ); 


Inputs

d           (1,:)     Degrees or [d;m;s] or string
m           (1,:)     Minutes
s           (1,:)     Seconds

Outputs

rad         (1,:)     Angle in radians

◆ DN2Date()

function DN2Date ( in  dN,
in  year 
)

Computes the date from the day number and year.

January 1 is day 1.


Form

dateTime = DN2Date( dN, year )


Inputs

dN            (1,1) Day number
year          (1,1) Year

Outputs

dateTime      (1,6) [year month day hour minute seconds]

References: Montenbruck, O., T.Pfleger, Astronomy on the Personal Computer, Springer-Verlag, Berlin, 1991, p. 12.


◆ DN2JD()

function DN2JD ( in  dN,
in  year 
)

Computes the Julian Date from the day number and year.

January 1 is day 1. If no arguments are given it returns the current Julian date.


Form

jD = DN2JD( dN, year )


Inputs

dN    (1,1) Day number
year    (1,1) Year

Outputs

jD    (1,1) Julian date

References: Montenbruck, O., T.Pfleger, Astronomy on the Personal Computer, Springer-Verlag, Berlin, 1991, p. 12.


◆ DNString2Date()

function DNString2Date ( in  s)

Converts a day number string to a date.


Form

dateTime = DN2Date( dN, year )


Inputs

dn           (1,1)  Day number
year         (1,1)  Year

Outputs

dateTime     (1,6)  [year month day hour minute seconds]

◆ DOGram()

function DOGram ( in  a,
in  c 
)

Compute the observability gramian for a discrete time system.


Form

[p, err] = DOGram( a, c )



Inputs

a                   State matrix
c                   Output matrix

Outputs

p                   Solution
err                 Norm of the error

◆ DoubleIntegratorRHS()

function DoubleIntegratorRHS ( in  x,
in  ignoredArg,
in  u,
in  mass 
)

Right hand side for a double integrator.


Form

xDot = DoubleIntegratorRHS( x, t, u, mass )


Inputs

x         (2,1)  [position;velocity]
t         (1,1)  Time
u         (1,1)  Control
mass      (1,1)  Mass

----—~

Outputs

xDot      (2,1)  d[position;velocity]/dt

◆ DQ2Mat()

function DQ2Mat ( in  q,
in  qDot 
)

Finds the derivative of a transformation matrix in terms of quaternions.


Form

dM = DQ2Mat( q, qDot )  


Inputs

q       (4,1)  Equivalent quaternion
qDot    (4,1)  Quaternion derivative

Outputs

dM      (3,3)  Derivative of orthonormal transformation matrix

◆ DQCE()

function DQCE ( in  phi,
in  gamma,
in  h,
in  rw,
in  rv 
)

Create an optimal estimator.

Create an optimal estimator given a discrete time model of the form


x[k+1] = phi x[k] + gamma w


The estimator will be of the form


xE = phi*xE + gamma*u + k*(y-h*xE)

Form

k = DQCE( phi, gamma, h, rw, rv )


Inputs

phi                 State transition matrix
gamma               Input matrix for plant noise
h                   Measurement matrix
rw                  Process noise
rv                  Measurement noise

Outputs

k                   Optimal gain

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, p. 452.


◆ DQCR()

function DQCR ( in  a,
in  b,
in  q,
in  r,
in  n 
)

Create a quadratic regulator.

Create a quadratic regulator of the form


u = -Kx minimizing the cost functional


J = †(1/2){u'ru + x'qx + u'nx + x'nu}dt.


Given the constraint:


x(k+1) = a x(k) + b u(k)

Form

k = DQCR( a, b, q, r, n )


Inputs

a                   Discrete time Plant matrix
b                   Discrete time Input matrix
q                   State cost matrix
r                   Input cost matrix
n                   State/input cost cross-coupling matrix

Outputs

k                   Optimal gain

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, pp. 435-438.


◆ DrawCAD()

function DrawCAD ( in  g,
in  drawNormals,
in  scale 
)

Draw a CAD model stored in the toolbox CAD format.

Can be loaded from LoadCAD or made from BuildCADModel. This function draws the components only without applying any body rotations. Phong lighting is used. Black is used for all edges.

Type DrawCAD for a demo loading a dxf file.


Form

h = DrawCAD( g, drawNormals, scale )


Inputs

g           (.)    CAD model data structure
drawNormals (1)    Draw normals for all outside components
scale       (1,1)  Scale factor for the quiver arrows (default 1)

Outputs

h     (1,:)  Handles to patch objects 

See also LoadCAD, patch


◆ DrawFOV()

function DrawFOV ( in  f,
in  l,
in  axesHandle 
)

Draw fields of view.

Type DrawFOV for a demo which draws two fields of view.


Form

DrawFOV( f, l, axesHandle )


Inputs

f           (:)   FOV data structure
.r    (3,1) Location
.b    (3,1) Unit boresight vector
.fOV  (1,1) Angle (rad)
l           (1,1) Length
axesHandle  (1,1) Handle of axes to draw on, or else makes new figure.

Outputs

None

◆ DrawImage()

function DrawImage ( in  hParent,
in  position,
in  file,
in  path,
in  width 
)

Draws an image in a figure window.

If file is empty you will be asked to select a file via uigetfile.


Form

i = DrawImage( hParent, position, file, path, width )


Inputs

hParent   (1,1)   Handle to the figure
position  (1,2)   [x,y] lower left corner (pixels)
file      (1,:)   File name
path      (1,:)   Path name
width     (1,1)   Width

Outputs

i         (:,:,:) Image

See also uigetfile, imread, image


◆ DrawSphere()

function DrawSphere ( in  R,
in  surfCol,
in  lineCol,
in  latMarks,
in  longMarks 
)

Draw a sphere with specified latitude and longitude lines.

Type DrawSphere for a demo.


Form

[fig, s] = DrawSphere( R, surfCol, lineCol, latMarks, longMarks )


Inputs :

R         (1,1) Radius
surfCol   (1,:) Surface color (character of 1 by 3 array)
lineCol   (1,:) Line color (character of 1 by 3 array)
latMarks  (1,:) Latitude mark angles
lonMarks    (1,:)   Longitude mark angles

Outputs :

fig       (1,1) Figure handle 
s         (1,1) Surface handle

◆ DrawTreeDiagram()

function DrawTreeDiagram ( in  hFig,
in  tree,
in  position,
in  buttonDownFunction 
)

Creates and draws a tree diagram.


Form

[q, sIndex] = DrawTreeDiagram( hFig, tree, position, buttonDownFunction )


Inputs

hFig               (1,:)  Figure handle
tree               {}     Tree cell array
position           (1,4)  [x y width height]
buttonDownFunction (1,:)  String of the form  function( xxxxx, 
The tree block id is substituded after xxxxx, to 
get function( xxxxx, 1 )

Outputs

q                  (1,1)  Data structure with the graphical display tree data
sIndex             {}     index into graphical tree

◆ DrawVertices()

function DrawVertices ( in  v,
in  f,
in  name,
in  blend 
)

Draw and object from vertices in a figure window using patch.

The object will be a uniform color. Type DrawVertices for a demo.


Form

DrawVertices( v, f, name, blend )


Inputs

v       (:,3) Vertices
f       (:,3) Faces
name    (1,:) Figure name
blend   (1,1) If true blend the vertex lines

Outputs

None

◆ DRiccati()

function DRiccati ( in  g)

Solves the discrete matrix Riccati equation.

Solves the matrix Riccati equation in the form


g = [a   r]
[q -a']


Since version 2.

Form

[sinf, rr] = DRiccati( g )


Inputs

g                   Input matrix 

Outputs

sinf                Steady-state solution
rr                  Repeated roots 1= repeated roots

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, pp. 435-438.


◆ DTAToDTS()

function DTAToDTS ( in  t)

Converts the date time array to the date time structure.

Typing DSTToDTA returns the clock time.


Form

dateTime = DTSToDTA( t )


Inputs

t           (1,6)   [year month day hour minute seconds 

Outputs

dateTime    (1,1)   Date/time structure
.year
.month                             
.day                             
.hour                             
.minute                             
.second

◆ DTSToDTA()

function DTSToDTA ( in  t)

Converts the date time structure to the date time array.

Typing DTSToDTA returns clock time


Form

dateTime = DTSToDTA( t )


Inputs

t          (1,1)   Date/time structure
.year
.month                             
.day                             
.hour                             
.minute                             
.second

Outputs

dateTime    (1,6)  [year month day hour minute seconds 

◆ DualListPlugIn()

function DualListPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create dual lists.

Typing DualListPlugIn is the same as DualListPlugIn('initialize')


Form

x = DualListPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifier    (1,:)  Modifier to the action
hFig        (1,1)  Handle to the figure
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  Depends on the action.

◆ EditDlg()

function EditDlg ( in  string,
in  defaultString,
in  waitTime 
)

Creates a dialog which requires a string as an answer.

Waits for a default time of 5 minutes.


Inputs

string          (1,:)     A text string 
defaultString   (1,:)     The default value of x
waitTime        (1,1)     Wait time before default is returned

Outputs

x               (1,:)     The string   

◆ EditScroll()

function EditScroll ( in  action,
in  modifier,
in  hFig,
in  position 
)

Implement a scrollable edit window.

tag = EditScroll( 'initialize', text, hFig, [10 10 200 100] )

Form

x = EditScroll( action, modifier, hFig, position )


Inputs

action    (1,:)    Action to perform
modifier  (1,:)    Modifier to the action
hFig      (1,1)    Figure handle
position  (1,4)    [left, bottom, width, height]

Outputs

x         (:,:)    The text

◆ EigenstructurePlugIn()

function EigenstructurePlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create an Eigenstructure GUI plug in.

Typing EigenstructurePlugIn is the same as EigenstructurePlugIn('initialize');


Form

x = EigenstructurePlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ EigEval()

function EigEval ( in  g,
in  hAxes 
)

Evaluate the eigenvalues and eigenvectors graphically.

The eigenvectors are normalized to 1.

Type EigVal for a demo.


Form

hPlot = EigEval( g, hAxes )


Inputs

g        (:)     Plant object of type statespace
hAxes    (1,1)   Figure handle

Outputs

hPlot    (1,1)   Handle to the plot

◆ EKFPredict()

function EKFPredict ( in  d)

Extended Kalman Filter prediction step.


Form

d = EKFPredict( d )


Inputs

d   (1,1)  EKF data structure
.m       (n,1)       Mean
.p       (n,n)       Covariance
.q       (n,n)       State noise
.f       (1,:)       Name of right hand side
.fX      (1,:)       Jacobian of right hand side
.fData   (1,1)       Data structure with data for f
.dT      (1,1)       Time step
.t       (1,1)       Time

Outputs

d   (1,1)  EKF data structure

◆ EKFUpdate()

function EKFUpdate ( in  d)

Extended Kalman Filter measurement update step.

All inputs are after the predict state (see EKFPredict). The h data field may contain either a function name for computing the estimated measurements or an m by n matrix. If h is a function name you must include hX which is a function to compute the m by n matrix is a linearized version of the function h.


Form

d = EKFUpdate( d )


Inputs

d   (1,1)  EKF data structure
.m       (n,1)  Mean
.p       (n,n)  Covariance
.h       (m,n)  Either matrix or name of function
.hX      (1,:)  Name of Jacobian for h
.y       (m,1) Measurement vector
.r       (m,m)  Measurement covariance vector
.hData   (1,1)  Datastructure for the h and hX functions

Outputs

d   (1,1)  EKF data structure
.m       (n,1)  Mean
.p       (n,n)  Covariance
.v       (m,1)  Residuals

◆ Ellipsd()

function Ellipsd ( in  a,
in  b,
in  c,
in  n 
)

Generates an ellipsoid using the equation.

2     2     2
x     y     z

— + — + — = 1

2     2     2
a     b     c

Generates three n-by-n matrices so that surf(x,y,z) produces a unit sphere.


Form

[x, y, z] = Ellipsd( a, b, c, n )


Inputs

a                     x-axis coefficient
b                     y-axis coefficient
c                     z-axis coefficient
n                     Number of facets

Outputs

x         (n,n)       x matrix
y         (n,n)       y matrix
z         (n,n)       z matrix

◆ EmptyBlock()

function EmptyBlock ( )

Produce an empty data structure used by the control functions.

x .g              (1,1) Complete block model of class statespace
.gBase          (1,1) Base model (cannot be separated into SISO elements)
.blockInputs    {:}   Inputs to block
.blockOutputs   {:}   Outputs from block
.sISOID         (1,1) ID of SISO element (not used here)
.sISO           (:)   SISO parameters
.g          (1,1) Controller statespace class
.name       (1,:) Controller name
.element    {:}   Controller type
.parameters {:}   Controller parameters
.inputs     {:}   Inputs
.outputs    {:}   Outputs  
.esa            (:)   Eigenstructure parameters
.lq             (:)   Linear quadratic parameters

Form

x = EmptyBlock


Inputs

None

Outputs

x      (1,1) Data structure defined above

◆ EmptySISO()

function EmptySISO ( )

Produce an empty data structure used by the control functions.

x  (:)   SISO parameters
.g          (1,1) Controller statespace representation
.name       (1,:) Controller name
.element    {:}   Controller type
.parameters {:}   Controller parameters
.inputs     {:}   Inputs
.outputs    {:}   Outputs  

Form

x = EmptySISO


Inputs

None

Outputs

x      (1,1) Data structure defined above

◆ Equal()

function Equal ( in  a,
in  b 
)

Returns one if a and b are identical.

This function calls itself recursively. a and b can be arrays, cell arrays or structures. Equal will be limited by the depth of recursion that you have set for Matlab.


Form

k = Equal( a, b )


Inputs

a           (1,1) A variable
b           (1,1) A variable

Outputs

k           (1,1) = 1 if they are identical

◆ ESAssign()

function ESAssign ( in  g,
in  lambda,
in  vD,
in  fC 
)

Apply eigenvector and eigenvalue assignment.

Type ESAssign for a demo.

Form

f = ESAssign( g, lambda, vD, fC )


Inputs

g               (:)      State space system of type statespace
lambda          (n)      Desired eigenvalues
vD              (:,n)    Desired eigenvectors
fC              (3,p)    Control constraint equation

Outputs

f                        Gain matrix

Reference: Andry, A. N., Jr., Shapiro, E.Y. and J.C. Chung, "Eigenstructure Assignment for Linear Systems," IEEE Transactions on Aerospace and Electronic Systems, Vol. AES-19, No. 5. September 1983.


◆ ESAssignDraper()

function ESAssignDraper ( in  g,
in  lambda,
in  vD,
in  r,
in  fC 
)

Apply eigenvector assignment using the Draper method.

vD is entered with nan where you don't
care about the value of the eigenvector.


Type EAssignDraper for a demo.

Form

f = ESAssignDraper( g, lambda, vD, r, fC )


Inputs

g               (:)      State space system of type statespace
lambda          (n)      Desired eigenvalues
vD              (:,n)    Desired eigenvectors
r               (:,n)    Weighting matrix
fC              (3,p)    Control constraint equation

Outputs

f                        Gain matrix

Reference: Orr H. A., "An Integrated Fire/Flight Control System for a Conventionally Configured A-10 Aircraft," CSDL-T-794, December 1982.


◆ Eul2Mat()

function Eul2Mat ( in  e)

Converts 3-2-1 Euler angles into an orthonormal transformation matrix.


Form

m = Eul2Mat( e )    


Inputs

e       (3)    Euler angles

Outputs

m       (3,3)  Orthonormal transformation matrix

◆ Eul2Q()

function Eul2Q ( in  e)

Converts 3-2-1 Euler angles to a quaternion.

Uses the half angle formulas.


Form

q = Eul2Q( e )


Inputs

e       (3,:)    Euler angles (rad)

Outputs

q       (4,:)    Equivalent quaternion

◆ EulDot2Rates()

function EulDot2Rates ( in  e,
in  wEul,
in  n 
)

Converts 3-2-1 Euler angle rates into angular velocity.

If only one input is given, the output is the transformation matrix.


Form

w = EulDot2Rates( e, wEul, n )


Inputs

e        (3)    Euler angles
wEul (3)    Angular rates
n    (1)    Orbit rate (for rotating frames only, optional)

Outputs

w      (3)    Euler angle rates

Reference: Hughes, Spacecraft Attitude Dynamics (1986), Eq. 25 p. 27


◆ EVAssgnC()

function EVAssgnC ( in  g,
in  lambda,
in  vD,
in  d,
in  rD,
in  w 
)

Use eigenvector assignment to design a controller.

Complex lambdas must be in pairs. Their corresponding eigenvectors
must also be complex. 


The design matrix, d.
One column per state.  Each row relates vD to the
plant matrix. For example, rows 7 and 8 relate column 3 in vD to
the plant. In this case vD(1,3) relates to state 2 and vD(2,4)
relates to state 3. vD need not have as many columns as states.


If the desired vD are eigenvectors then d is the identity matrix
If the desired vectors are directions in the output then D = c
If components of v are no concern the corresponding column of D
should be zero.


rD gives the rows in D per eigenvalue    
Each column is for one eigenvalue
i.e. column one means that the first three rows of  D relat
to eigenvalue 1 

Form

[k, v] = EVAssgnC( g, lambda, vD, d, rD, w )


Inputs

g               (:)      State space system of type statespace
lambda          (n)      Desired eigenvalues
vD              (:,n)    Desired eigenvectors
d               (:,n)    Design matrix
rD              (n)      Rows in d per eigenvalue
w               (:,n)    Weighting vectors

Outputs

k                        Gain matrix
v                        Achieved eigenvectors

Reference: Stevens, B.L., Lewis, F.L. Aircraft Control and Simulation John Wiley & Sons, 1992, pp. 342-358. Andry, A. N., Jr., Shapiro, E.Y. and J.C. Chung, "Eigenstructure Assignment for Linear Systems," IEEE Transactions on Aerospace and Electronic Systems, Vol. AES-19, No. 5. September 1983.


◆ EVAssgnE()

function EVAssgnE ( in  g,
in  lambda,
in  vD,
in  d,
in  rD 
)

Use eigevector assignment to design an estimator.

Complex lambdas must be in pairs. Their corresponding eigenvectors 
must also be complex. 


The design matrix, d.
One column per state.  Each row relates vD to the
plant matrix. For example, rows 7 and 8 relate column 3 in vD to
the plant. In this case vD(1,3) relates to state 2 and vD(2,4)
relates to state 3. vD need not have as many columns as states.


rD gives the rows in D per eigenvalue    
Each column is for one eigenvalue
i.e. column one means that the first three rows of  D relat
to eigenvalue 1


When you create statespace it should be:


g = statespace( a, [], c );

Form

[k, v] = EVAssgnE( g, lambda, vD, d, rD )


Inputs

g               (:)      Statespace system
lambda          (n)      Desired eigenvalues
vD              (:,n)    Desired eigenvectors
d               (:,n)    Design matrix
rD              (n)      Rows in d per eigenvalue

Outputs

k                      Gain matrix
v                      Achieved eigenvectors

◆ EVDesMat()

function EVDesMat ( in  nStates,
in  kAssign 
)

Create the design matrix for the eigenstructure assignment technique.


Form

d = EVDesMat( nStates, kAssign )


Inputs

nStates         (1,1)    Number of states in the plant
kAssign         (m)      States to be controlled

Outputs

d               (m,n)    Design matrix

◆ ExportToPSSMatrix()

function ExportToPSSMatrix ( in  fileName,
in  varargin 
)

Export two dimensional matrices to a file that can be read by pss_matrix.

You can then read from the file in C++ using:

#include <fstream.h>

#include <iostream.h>

ifstream matrixIn( fileName ); matrixIn >> matrix1; matrixIn >> matrix2; matrixIn.close();


Form

ExportToPSSMatrix( fileName, matrix1, matrix2, ... )


Inputs

fileName       (1,:)  File name
matrix1        (:,:)  First matrix
matrix2        (:,:)  Second matrix
...            (:,:)  Additional matrices

Outputs

None

◆ Extrude()

function Extrude ( in  z,
in  c,
in  topClosed,
in  bottomClosed,
in  cI 
)

Generate an object from cross sections.

Type Extrude for a demo.


Form

[v, f] = Extrude( z, c, topClosed, bottomClosed, cI )


Inputs

z          (1,n) z locations
c          (n)   Crossection data
.x (1,m) x locations
.y (1,m) y locations
topOpen          1 if top is closed
bottomOpen       1 if bottom is closed
cI         (n)   Interior crossection data
.x (1,m) x locations
.y (1,m) y locations

Outputs

v         (:,3)  Vertices
f         (:,3)  Faces

◆ ExtrudeFromProfile()

function ExtrudeFromProfile ( in  z,
in  r,
in  topClosed,
in  bottomClosed,
in  n,
in  rI 
)

Extrude from a radial profile.

Can have an inner and outer radius. Type ExtrudeFromProfile for a demo.


Form

[v, f] = ExtrudeFromProfile( z, r, topClosed, bottomClosed, n, rI )


Inputs

z          (1,m) z locations
r          (m)   Radii
topOpen    (1,1) 1 if top is closed, default is open
bottomOpen (1,1) 1 if bottom is closed, default is open
n          (1,1) Number of circumferential divisions
rI         (m)   Inner radii

Outputs

v          (:,3) Vertices
f          (:,3) Faces

See also: Extrude


◆ FFTEngy()

function FFTEngy ( in  y,
in  tSamp,
in  aPeak,
in  noLog 
)

Plot the energy in a signal.

Will annotate peaks if y is a 1-dimensional array. y may be entered by column or row, but the longest dimension will be assumed to be the variation by time.


Form

[e, w] = FFTEngy( y, tSamp, aPeak, noLog )


Inputs

y             (:,n) Sequence
tSamp         (1,1) Sampling period
aPeak         (1,1) Anotate peaks about this fraction of max
noLog         (1,1) If input will not use a log plot

Outputs

e                   Energy
w                   Frequencies (rad/sec)        

◆ Figui()

function Figui ( in  h,
in  fs,
in  pos 
)

User-interface to manage figure windows.


Form

Figui( h )


Inputs

h            (1,:)   Array of figure handles. Optional. If not
provided, all current figure handles will be used.
fs           (1,1)   Font size to use for button text.
pos                  Position

Outputs

none

◆ FileFullpath()

function FileFullpath ( in  filename,
in  overwrite 
)

Save the file at the path of the calling function.

Use dbstack to find the absolute path of the calling function, and create a filename using the path.

Example:

fullname = FileFullpath( 'MyFile.txt', false )
fullname = '/Path/To/CallingFolder/MyFile_1.txt'

Form

fullname = FileFullpath( filename, overwrite )



Inputs

filename   ''    The string name of the file, with extension. If no
extension is given it is assumed to be a mat-file.
overwrite  (1)   Flag whether to overwrite the existing file - default is 
true - or to append the name of the file with a modifier 
should it already exist. Filenames will be appended 
with an underscore and a  number starting with _0.

Outputs

fullname   ''    Full qualified filename

◆ FindDirectory()

function FindDirectory ( in  d,
in  ignoredArg 
)

Returns the path to a directory.

The default behavior is to return the first match. If a second argument is given the function will return all matches. d may be a partial path provided it is within the current directory.


Form

p = FindDirectory( d, ~ )


Inputs

d        (1,:) Name of the directory
~              Any second input, returns all matches

Outputs

p        (1,:) Path to the files in the directory OR
{:}   Cell array of paths if 'all' option is specified

◆ Finder()

function Finder ( in  action,
in  modifier 
)

GUI to find occurrences of a text string in m-files on your MATLAB path.

Search the whole path or a selected directory. Choose case sensitivity and whether or not to include comments.

This GUI enables you to find usage of a function or variable, or to search for keywords across functions in your toolboxes.


Form

x = Finder(action, modifier)


Inputs

action          (1,:)   Action to be taken by the gui 
(used only for callbacks)
modifier        (1,:)   Modifier to the action

Outputs

x

◆ FindInFiles()

function FindInFiles ( in  string,
in  caseSensitive,
in  wholeWord,
in  includeComments,
in  fileSet 
)

Find all files that contain a specified string.


Form

[files,lineNums,lines] = FindInFiles( string,caseSensitive,wholeWord, 
includeComments, fileSet );


Inputs

string           (:)      Text string to search for.
Note: If no string is provided, or if '' is provided, the
function will return the entire searchable file set.
(Optinal. Default is '')


caseSensitive    (1)      Flag indicating whether the search should be case sensitive
(Optional. Default is NOT case sensitive, 0)


wholeWord        (1)      Flag indicating whether to search for only the whole word or not
(Optional. Default is NOT to constrain search to whole word, 0)


includeComments  (1)      Flag indicating whether to include comments in the search
0 - do NOT include comments in the search
1 - INCLUDE comments in the search (no restriction)
2 - allow ONLY comments to be included in the search
Note: If a "%" symbol appears before the first instance of
the string in a line, the line is considered a comment.
(Optional. Default is to INCLUDE comments in the search, 1)


fileSet          {:}      The searchable file/folder set. This is a cell array of file and/or
folder names to search over. Either the full file/folder name 
(directory path prepended) or the partial name may be used.
Whenever listing files, the file extension MUST be included.
Note: If only a partial filename is provided, the file that
appears FIRST in the Matlab search path will be used.
(Optional. Default is to search over all m-files in the path)

Outputs

files           {N,1}        Cell array list of all "N" files containing the string
(subject to case sensitivity and comment inclusion constraints)


lineNums        {1,N}(1,M)   Cell array of "N" vectors. Each vector is a list of line numbers
where the string was found.
Note: If no string is supplied, this output is just {}


lines           {1,N}{1,M}   Cell array of "N" cells, each containing "M" lines of text. 
Each line of text is an entire line found in the corresponding file 
that contains the string.
Note: If no string is supplied, this output is just {}

◆ FindPeaks()

function FindPeaks ( in  x,
in  y 
)

Find peaks of the inputs by looking at slopes.


Form

[xP, yP, kP, ind] = FindPeaks( x, y )


Inputs

x             (1,:) X
y             (n,:) Y

Outputs

xP            (n,:) values of x where y has peaks
yP            (n,:) Peak values of y
kP            (n,:) Maximum number of peaks for each y
ind           (n,:) Indexes to peaks for each row

◆ FindRequiredFiles()

function FindRequiredFiles ( in  FunctionIn,
in  DirectoryIn,
in  verbose 
)

Find the files required by a function or a script in order to run.

i.e. the *.mat files


All files located under the matlabroot directory are ignored,
because they are assumed to be built-in MATLAB files.


Since version 10.

Form

[names,dirs] = FindRequiredFiles( FunctionIn, DirectoryIn, verbose )


Inputs

FunctionIn   {n}  String or Cell array of function names
DirectoryIn  {n}  String or Cell array of corresponding directory names
verbose      (1)  Verbosity flag, defaults false

Outputs

frequired    {:}  Cell array of required file names with extensions
drequired    {:}  Cell array of corresponding directory names

◆ FindSolsticeOrEquinox()

function FindSolsticeOrEquinox ( in  type,
in  year 
)

Finds the Julian Date for solstices and equinoxes.

The default type is spring equinox and the default year is 2001. A four digit year must be entered (unless you are interested in years prior to 1000 AD.) You can enter strings as 'winter solstice 2002' See also FSolstice.


Form

jD = FindSolsticeOrEquinox( type, year )


Inputs

type       (1,:)  'fall equinox',   'winter solstice'
'spring equinox', 'summer solstice'
year       (1,1)  Year (Default is 2001)

Outputs

jD         (1,1)  Julian Date

◆ FindStringInFiles()

function FindStringInFiles ( in  z,
in  d 
)

Finds all instances of the string z in directory d.

Recursively searches through subdirectories.

Form

FindStringInFiles( z, d )


Inputs

z         {}      String to match
d         (1,:)   Complete pathname to the directory

Outputs

None

◆ FirstLineOfCode()

function FirstLineOfCode ( in  filename)

Return the first line of code for a m-file.

This is the first line that has characters but does not begin with a comment. If no lines are found, empty '' is returned.


Form

line = FirstLineOfCode( filename );


Inputs

fileName     (1,:)     File name

Outputs

line         (1,:)     First line of code

◆ FixLineEndings()

function FixLineEndings ( in  s)

Make line endings consistent with the platform.


Form

s = FixLineEndings( s )


Inputs

s              (1,:)   String

Outputs

s              (1,:)   String

◆ fixpopupuicontrol()

function fixpopupuicontrol ( in  fig)

This function found on Mathworks website as a bug-fix for MATLAB 7.

GUIs with pop-up menus would flash on the screen and bog down the CPU.

Form

fixpopupuicontrol(fig)


Inputs

fig             (1)     Figure handle

Outputs

none

◆ flength()

function flength ( in  f)

Give the length of a file in bytes.


Form

n = flength( f )


Inputs

f             (1,1)   File id

Outputs

n             (1,1)   Length   

◆ FNLSpring()

function FNLSpring ( in  x,
in  ignoredArg,
in  fData 
)

Nonlinear estimator spring model.

Used by CDKFDemo.


Form

[xDot, fData] = FNLSpring( x, t, fData )


Inputs

x         (1,1)  State
t         (1,1)  Time
fData     (1,1)  Data structure
.k  (1,1) coefficient
.x0 (1,1) nominal x

Outputs

xDot      (:)    Derivative
fData     (1,1)  Data structure
.k  (1,1) coefficient
.x0 (1,1) nominal x

◆ FOPID()

function FOPID ( in  e,
in  d 
)

Fractional order PID controller.

Implements a fractional order PID. The order can be from 0 to 1. 1 is a normal PID.

d.L gives the minimum and maximum terms to use. Below d.L(1), u will be zero.

Type FOPID to compare an order 1 PID with an order 0.5 PID and a traditional PID.


Form

d = FOPID
[u,d] = FOPID(e,d)


Inputs

e (1,1) Input
d (.)   Data structure
.lambda (1,1) The integral order (0 to 1)
.mu     (1,1) The derivative order (0 to 1)
.L      (1,2) Memory length [min max]
.h      (1,1) Time step
,kP     (1,1) Proportional gain
,kI     (1,1) Integral gain
,kD     (1,1) Derivative gain
.e      (1,:) Memory of e

Outputs

u (1,1) Output
d (.)   Data structure (see above) with d.e updated

Reference: Junhe Wan, Bo He, Dianrui Wang, Tianhong Yan and Yue Shen, "Fractional-Order PID Motion Control for AUV Using Cloud-Model-Based Quantum Genetic Algorithm," IEEE Access, https://ieeexplore.ieee.org/document/8817916/ references::references


◆ Fractal()

function Fractal ( in  v,
in  f,
in  n,
in  sigma 
)

Generates fractals.

Pass a vertex list, face list, depth of the fractal generation and the standard deviation of the height increment. This routine requires that the face list contain only triangles. The algorithm adds new vertices at each midpoint displaced in the direction of the triangle normal a random amount determined by sigma. Each pass generates 7 triangles for each existing triangle.

Type Fractal for a demo.


Inputs

v           (:,3) Vertex list
f           (:,3) Face list
n           (1,1) Fractal depth
sigma       (1,1) Standard deviation of height change

Outputs

v           (:,3) Vertex list
f           (:,3) Face list

◆ FResp()

function FResp ( in  a,
in  b,
in  c,
in  d,
in  iu,
in  iy,
in  w,
in  uPhase,
in  pType 
)

Compute the frequency response of the system given a, b, c and d.

.
x = ax + bu
y = cx + du


for the input vector iu, and output vector iy. If no output arguments
are given it will automatically display Bode plots for all channels.


If only 1 output is requested, the complex values will be output.

Form

[mag, phase, w, io] = FResp( a, b, c, d, iu, iy, w, uPhase, pType )
[mag, phase, w, io] = FResp( num, den, w, uPhase, pType )


Inputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix
iu                  Inputs  ( = 0, or leave out for all)
iy                  Outputs ( = 0, or leave out for all)
w            (1,:)  Frequency vector
uPhase       (1,:)  Unwrap phase = 'wrap' to wrap it within 180 deg
pType        (1,:)  'bode' or 'nichols'

Outputs

mag                 Magnitude vector
phase               Phase angle vector (deg)
w            (1,:)  Frequencies computed
io                  Input/output vector per plot [input,output;...]

References: Laub, A., "Efficient Multivariable Frequency Response Computations," IEEE Transactions on Automatic Control, Vol. AC-26, No. 2, April 1981, pp. 407-408. Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, pp. 368-370.


◆ FRespG()

function FRespG ( in  f,
in  iu,
in  iy,
in  w,
in  uPhase,
in  pType 
)

Compute the frequency response given the statespace class as input.

.
x = ax + bu
y = cx + du


for the input vector iu, and output vector iy. If no output arguments
are given it will automatically display Bode plots for all channels.


If only 1 output is requested, the complex values will be output.

Form

[mag, phase, w, io] = FRespG( f, iu, iy, w, uPhase, pType )


Inputs

f                   State space system of type statespace
iu                  Inputs  ( = 0, or leave out for all)
iy                  Outputs ( = 0, or leave out for all)
w                   Frequency vector
uPhase              Unwrap phase = 'wrap' to wrap it within 180 deg
pType               'bode' or 'nichols'

Outputs

mag                 Magnitude vector    
phase               Phase angle vector (deg)
w                   Frequencies computed
io                  Input/output vector per plot [input,output;...]

References: Laub, A., "Efficient Multivariable Frequency Response Computations," IEEE Transactions on Automatic Control, Vol. AC-26, No. 2, April 1981, pp. 407-408. Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, pp. 368-370.


◆ FRespPlot()

function FRespPlot ( in  mag,
in  phase,
in  w,
in  pType,
in  iu,
in  iy 
)

Plot the frequency response of the system in Bode or Nichols form.


Form

FRespPlot( mag, phase, w, pType, iu, iy );


Inputs

mag          (1,:)  Magnitude response
phase        (1,:)  Phase response
w            (1,:)  Frequency vector
pType         (:)   'bode' or 'nichols'
iu                  Inputs  ( = 0, or leave out for all)
iy                  Outputs ( = 0, or leave out for all)

Outputs

None

◆ Frustrum()

function Frustrum ( in  rL,
in  r0,
in  l,
in  n,
in  topOpen,
in  bottomOpen,
in  angleStart,
in  angleEnd 
)

Generate a frustrum of a cone.

Type Frustrum for a demo.


Form

[v, f] = Frustrum( rL, r0, l, n, topOpen, bottomOpen, thetaStart, thetaEnd )


Inputs

rL           (1,1) Top radius    (z = l)
r0           (1,1) Bottom radius (z = 0)
l            (1,1) Length
n            (1,1) Number of divisions
topOpen      (1,1) 1 if top is open
bottomOpen   (1,1) 1 if bottom is open
angleStart   (1,1) Start angle (default 0)
angleEnd     (1,1) End angle (default 2*pi)

Outputs

v           (:,3) Vertices
f           (:,3) Faces

◆ FSWClock()

function FSWClock ( in  action,
in  d 
)

This routine implements the flight software clock.


Form

t = FSWClock( action, d );


Inputs

action        (1,:)     Action to be performed        
d             (1,1)     Data structure for inputs

Outputs

t             (1,1)     Data structure with outputs. Valid only
with action 'update' and 'get telemetry'

◆ FunNames()

function FunNames ( in  path)

Get Function Names.


Form

c = FunNames( path )


Inputs

path          (1,:)   Directory path

Outputs

c             (n,:)   Names of all m files

◆ FXNLSpring()

function FXNLSpring ( in  x,
in  ignoredArg,
in  d 
)

Jacobian of RHSUKF.

Partial of the right-hand-side with respect to the position.


Form

f = FXNLSpring( x, t, d )


Inputs

x         (1,1)  Position
t         (1,1)  Time (not used)
d          (.)   Data structure
.w   (1,1) Spring constant

Outputs

f         (1,1)  dF/dx

◆ GasProperties()

function GasProperties ( in  gas)

Returns gas properties.


Form

[m, gamma] = GasProperties( gas )


Inputs

gas           (1,:)  Name of gas to be used. One of:
'hydrogen', 'helium', 'nitrogen', 'air',
'argon', 'krypton'

Outputs

m             (1,1)  Molecular weight
gamma         (1,1)  Ratio of specific heats

◆ Gen2nd()

function Gen2nd ( in  zz,
in  wz,
in  zp,
in  wp,
in  tSamp,
in  sType 
)

Creates a second order transfer function.

s^2/wz^2 + 2 zz s/wz + 1
K(s) = ------------------------
s^2/wp^2 + 2 zp s/wp + 1

Form

[a, b, c, d] = Gen2nd( zz, wz, zp, wp, tSamp, sType )


Inputs

zz                   Damping ratio of the zero pair
wz                   Undamped natural frequency of the zero pair
zp                   Damping ratio of the pole pair
wp                   Undamped natural frequency of the pole pair
tSamp                Sampling frequency
sType                State equation type ('Delta' or 'Z')

Outputs

a                    Plant matrix
b                    Input matrix
c                    Measurement matrix
d                    Feedthrough matrix

References: Wie, B., K. Byun, "New Generalized Structural Filtering Concept for Active Vibration Control Synthesis," J. Guidance and Control, Vol. 12, No. 2, March-April 1989, pp. 147-154.


◆ GeomPatch()

function GeomPatch ( in  d,
in  cData,
in  cMap 
)

Get vertices for surfaces of revolution, ellipsoids and cylinders.

All surfaces, except for ellipsoids, are closed. Type GeomPatch for a demo.


Form

[v, f, c] = GeomPatch( d, cData, cMap )


Inputs

d           (.)   Data structure
Surface of revolution: d.a, d.n, d.zUpper, d.zLower
d.a          r as a function of polynomial z
a(1)*z^n + a(2)*z^(n-1)... a(n)*z^0]
d.n          Number of divisions
d.zUpper     Upper z limit
d.zLower     Lower z limit


Cylinder: d.rU, d.rL, d.zUpper, d.zLower, d.n
d.rU         Upper radius
d.rL         Lower radius
d.zUpper     Upper z limit
d.zLower     Lower z limit
d.endcap     Any value creates endcaps   


Ellipsoid: d.a, d.b, d.c, d.thetaUpper, d.n
d.a          X radius
d.b          Y radius
d.c          Z radius
d.thetaUpper Upper angle. Ranges from 0 to thetaUpper
d.n          Number of divisions


The default value for n is 6.


cData       (m,p) Indexes to the color map where the values range
from 1 to n
cMap        (n,3) Color Map

Outputs

v           (:,3) Vertices
f           (:,3) Faces
c           (:,3) Vertex color data where the number of rows equal
the number of vertices

◆ GetCurrentGUIObject()

function GetCurrentGUIObject ( in  hFig)

Gets the last uicontrol that was hit.


Form

h = GetCurrentGUIObject( hFig )


Inputs

hFig          (1,1)   Figure handle

Outputs

h             (1,1)   Object handle     

◆ GetEntry()

function GetEntry ( in  h,
in  d,
in  errMsg 
)

Gets the input from a vector of graphics handles and determines.

if the input entries are valid.


Form

[x, valid, e] = GetEntry( h, d, errMsg )


Inputs

h        (n)    Vector of graphics handles
d        (1|n)  Data structure of valid parameters
Must enter either 1 or n data structures


Field       Default     Description
-----       -------     -----------
.type         'scalar'    {'scalar','vector','matrix','string'}
.empty         'no'       'yes' = empty entry is valid
.integer       'no'       'yes' = only integers allowed
.max            inf        maximum allowable value 
.min           -inf        minimum allowable value 
.maxElements     1         maximum number of elements for scalar/vector
.minElements     1         minimum number of elements for scalar/vector
.maxColumns     inf        maximum number of columns for matrix
.minColumns      1         minimum number of columns for matrix
.maxRows        inf        maximum number of rows for matrix
.minRows         1         minimum number of rows for matrix
.complex       'no'       'yes' = complex values allowed
.maxImag        inf        maximum allowable imaginary value
.minImag       -inf        minimum allowable imaginary value
.maxComplexMag  inf        maximum allowable complex magnitude
.minComplexMag -inf        minimum allowable complex magnitude


errMsg   (1)    1 = show default error dialog boxes (default is 1)

Outputs

x        {n}    Cell array containing field input. If a numerical value
is desired and the entry is valid, the numerical value
is returned in the cell array. Otherwise, the entered 
string is returned.
If only one handle is entered and the entry is numeric,
x is a scalar/vector/matrix, not a cell array.
Vector output is a column vector.
valid    (n)    1 = valid
e        (n)    Data structure with same fields as d 
indicating which error occured. 1 = error, [] = no error.

◆ GetFileRoot()

function GetFileRoot ( in  s)

Get the root name of a file (without the .xxx)


Form

r = GetFileRoot( s )


Inputs

s             (1,:)   Filename or cell array of filenames

Outputs

r             (1,:)   Filename or cell array of filenames

◆ GetFileSuffix()

function GetFileSuffix ( in  s)

Get the suffix of a file, i.e.

the xxx of yyyyy.xxx.


Form

s = GetFileSuffix( s )


Inputs

s             (1,:)   Filename

Outputs

s             (1,:)   Filename

◆ GetHeaders()

function GetHeaders ( in  p)

Finds all files in the directory d.

Recursively searches through subdirectories. Extract the headers. The returned data structure:

d.fileName d.header d.fileDirectory


Form

d = GetHeaders( p )


Inputs

p           (1,:)   Complete pathname to the directory

Outputs

d         {}      Data structure

◆ GetInputFromString()

function GetInputFromString ( in  s)

Generates an output from a string.

s may be a matrix, a workspace variable, a function with or 
without arguments or a .mat file.


e.g.
s = [1;2;2];
s = QZero
s = QForm( q, v )
s = a


where a, q and v are workspace variables


Type GetInputFromString for a demo.

Form

[x, err] = GetInputFromString( s )


Inputs

s       (1,:)     String

Outputs

x       :         Value
err     (1,:)     Error  message

◆ GetListString()

function GetListString ( in  h)

Get an element from a list uicontrol.

Returns empty if there is no string or the value of the uicontrol is 0.


Form

s = GetListString( h )


Inputs

h          (1,1) Handle to the string

Outputs

s        (1,:) String

◆ GetModificationDate()

function GetModificationDate ( in  fileName,
in  p 
)

Gets the modification date.


Form

d = GetModificationDate( fileName, p )


Inputs

fileName     (1,:)     File name
p            (1,:)     Path

Outputs

d            (1,1)     Date number

◆ GetNewTag()

function GetNewTag ( in  name)

Get a new tag to uniquely identify a figure.

Uses clock and rand to generate a unique string.


Form

tag = GetNewTag( name )


Inputs

name        (1,:)  Name of the figure

Outputs

tag         (1,:)  Tag

◆ GetUIElement()

function GetUIElement ( in  h,
in  property 
)

Get certain properties of UIElements.

property

'visible' 'position' 'datastructure'

If the handle is for a uicontrol it will return the property of that uicontrol.


Form

x = GetUIElement( h, property )


Inputs

h          (:)    Handle
property   (1,:)  Property

Outputs

x          {:}    Depends on the property

◆ GND()

function GND ( in  num,
in  den,
in  w 
)

Compute the frequency response given a numerator/denominator pair.

y(s) = num(s)*u(s)/den(s)


G(s) = num(s)/den(s)


This is a multi-output, single-input system


Each column will give the value for G(s) for that
frequency.

Form

[g,nu,w] = GND(num,den,w)


Inputs

num                 Transfer function numerator(s)
den                 Transfer function denomenator(s)
w                   Frequency vector

Outputs

g                   Frequency response matrix
nu                  Number of inputs
w                   Frequency vector

References: Laub, A., "Efficient Multivariable Frequency Response Computations," IEEE Transactions on Automatic Control, Vol. AC-26, No. 2, April 1981, pp. 407-408. Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, pp. 368-370.


◆ GPMargin()

function GPMargin ( in  m,
in  p,
in  w 
)

Computes gain and phase margins from magnitude and phase.


Form

[gM, wG, pM, wP] = GPMargin( m, p, w )
[gM, wG, pM, wP] = GPMargin( g, w )


Inputs

m                 Gain (db) or complex transfer function
p                 Phase (deg)
w                 Frequency vector

Outputs

gM                Gain margin (dB)
wG                Frequencies of gain crossovers (rad/sec)
pM                Phase margins (deg)
wP                Frequencies of phase crossovers   (rad/sec)         

◆ GPoly()

function GPoly ( )

Graphical interface to create a polygon.

The user clicks with the mouse to create points on a polygon. When the last point is within the threshold of the first the polygon is determined to be closed.


Form

p = GPoly


Inputs

None

Outputs

p       (2,:)   Matrix of polygon vertices

◆ GSS()

function GSS ( in  a,
in  b,
in  c,
in  d,
in  iu,
in  iy,
in  w 
)

Compute the multivariable frequency response of the system.

.
x = ax + bu
y = cx + du


or


G(s) = c*inv(sI-a)*b + d


y(s) = G(s)*u(s)


For example, for 3 outputs and 2 inputs g is of the form


w(1)               w(2)       ...
output 1 [ input 1 input 2 | input 1 input 2 |... ]
output 2 [ input 1 input 2 | input 1 input 2 |... ]
output 3 [ input 1 input 2 | input 1 input 2 |... ]

Form

[g,nu,w] = GSS(a,b,c,d,iu,iy,w)


Inputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix
iu                  Inputs  ( = 0, or leave out for all)
iy                  Outputs ( = 0, or leave out for all)
w                   Frequency vector

Outputs

g                   Frequency response matrix
nu                  Number of inputs
w                   Frequency vector

References: Laub, A., "Efficient Multivariable Frequency Response Computations," IEEE Transactions on Automatic Control, Vol. AC-26, No. 2, April 1981, pp. 407-408. Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, pp. 368-370.


◆ GUIColors()

function GUIColors ( in  action,
in  modifier 
)

GUI for setting interface colors.

Saves the values in the file GUIColors.mat.


Typing GUIColors is the same as GUIColors('initialize')

Form

x = GUIColors( action )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifier    (1,1)  Modifier to the action

Outputs

x           (1,3) Color

◆ HasOptimizationToolbox()

function HasOptimizationToolbox ( )

Returns 1 if a licensed optimization toolbox is in your path.


Form

y = HasOptimizationToolbox


Inputs


Outputs


◆ HierarchicalListPlugIn()

function HierarchicalListPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback,
in  params 
)

Create and manages a hierarchical list.

Each element of the list is

h(k).name        = 'mike';
h(k).parent      = '';
h(k).child       = {'pete'};
h(k).data        = ...;         Data can be anything.


Initialize

tag = HierarchicalListPlugIn( 'initialize', h, figureHandle, position, callback )


API

HierarchicalListPlugIn( 'add',    tag, h ) % Parent can be empty
HierarchicalListPlugIn( 'delete', tag )
HierarchicalListPlugIn( 'show',   tag )
HierarchicalListPlugIn( 'hide',   tag )
HierarchicalListPlugIn( 'set',    tag, d )


d   = HierarchicalListPlugIn( 'get', tag ) % Gets the entire list


Get the name of the selected element
s   = HierarchicalListPlugIn( 'get selection', tag )
s   = HierarchicalListPlugIn( 'get data for selection', tag )
s   = HierarchicalListPlugIn( 'get list', tag )

Form

x = HierarchicalListPlugIn( action, modifier, hFig, position, callback, params )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifier    (1,:)  Modifier to the action
hFig        (1,1)  Handle to the figure
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui
params      {:}    Parameter pairs for the list uicontrol

Outputs

x           (1,1)  Depends on the action.

◆ HMS2Deg()

function HMS2Deg ( in  h,
in  m,
in  s 
)

Convert hours, minutes and seconds to degrees.

See also HMS2Rad.

Form

a = HMS2Deg( h, m, s )
a = HMS2Deg( [h;m;s] )


Inputs

h           (1,:) Hours
m           (1,:) Minutes
s           (1,:) Seconds


or


h           (3,:) [Hours; Minutes; Seconds]

Outputs

a            (1,:)    Angle in degrees

◆ HMS2Rad()

function HMS2Rad ( in  h,
in  m,
in  s 
)

Convert hours, minutes and seconds to radians.


Form

a = HMS2Rad( h, m, s )
a = HMS2Rad( [h;m;s] )
a = HMS2RAD( h );


Inputs

h             (1,:) Hours or string
m             (1,:) Minutes
s             (1,:) Seconds


or


h             (3,:) [Hours; Minutes; Seconds]

Outputs

a             (1,:)   Angle in radians

◆ HNLSpring()

function HNLSpring ( in  x,
in  ignoredArg,
in  hData,
in  ignoredArg 
)

Nonlinear estimator measurement spring model.


Form

hData = HNLSpring;
[y, h] = HNLSpring( x, t, hData, k )


Inputs

x         (2,1)   State
t         (1,1)   Time
hData     (.)     Data structure
.alpha (1,1) coefficient
k         (1,1)   Not used

Outputs

y         (:)    Output
h         (1,1)  Derivative of y with respect to x

◆ HoopStress()

function HoopStress ( in  r,
in  p,
in  sigma,
in  type 
)

Computes the thickness of a pressure vessel.

The default type is 'cylinder'. If there are no outputs it creates a plot.

Type HoopStress for a demonstration of a 0.2 m radius pressure vessel with a titanium shell.


Form

t = HoopStress( r, p, sigma, type )


Inputs

r        (1,1) Radius (m)
p        (1,:) Pressure (N/m^2)
sigma    (1,1) Stress (N/m^2)
type     (1,:) 'cylinder' or 'sphere'

Outputs

t        (1,:) Thickness (m)

Reference: http://www.efunda.com/formulae/solid_mechanics/ mat_mechanics/pressure_vessel.cfm


◆ IC()

function IC ( in  g,
in  x,
in  dT,
in  nSim 
)

Generate a response to an initial condition vector.


Form

[y, x] = IC( g, x, dT, nSim )


Inputs

g                      State space system of type statespace
x                      Initial state vector
dT                     Time step
nSim                   Number of steps

Outputs

y                      Response
x                      State response

◆ IC623X3()

function IC623X3 ( in  x)

Convert an inertia matrix from a 1x6 to a 3x3 format.

The original form is

[Ixx Iyy Izz Ixy Ixz Iyz]

to

[Ixx Ixy Ixz Ixy Iyy Iyz Ixz Iyz Izz]


Form

y = IC623X3( x )


Inputs

x           (1,6)     [Ixx Iyy Izz Ixy Ixz Iyz]

Outputs

y           (3,3)     Inertia matrix

◆ IConv()

function IConv ( in  IVec)

Transform a 6x1 compact inertia vector into a 3x3 inertia matrix.

Vector form:   [Ixx; Iyy; Izz; Ixy; Ixz; Iyz]

Form

IMat = IConv( IVec )


Inputs

IVec          (6,1)    Compact inertia vector

Outputs

IMat          (3,3)    Full inertia matrix

◆ IConvP()

function IConvP ( in  IMat)

Transform a a 3x3 inertia matrix into 6x1 compact inertia vector.

Vector form:   [Ixx; Iyy; Izz; Ixy; Ixz; Iyz]

Form

IVec = IConvP( IMat );


Inputs

IMat          (3,3)    Full inertia matrix

Outputs

IVec          (6,1)    Compact inertia vector

◆ Icosahedron()

function Icosahedron ( )

Generate an icosahedron inscribed in a unit sphere.


Form

[v, f] = Icosahedron


Inputs

None

Outputs

v       (:,3)     Vertices
f       (:,3)     Faces

◆ IEKFUpdate()

function IEKFUpdate ( in  d)

Iterated Extended Kalman Filter measurement update step.

All inputs are after the predict state (see KFPredict).

Form

d = IEKFUpdate( d )


Inputs

d   (1,1)  EKF data structure
.m       (:,1)       Mean
.p       (:,:)       Covariance
.h       (:,n)       Either matrix or name of function
.hX      (1,:)       Name of Jacobian for h
.nIts    (1,1)       Number of iterations

Outputs

d   (1,1)  EKF data structure
.m       (:,1)       Mean
.p       (:,:)       Covariance
.v       (m,1)       Residuals

◆ ImageOverlay()

function ImageOverlay ( in  x,
in  wData,
in  tBoxes 
)

This function displays an image file and overlays text boxes.

The image file is in a .mat file. To generate the image:

xPict = imread('filename');
save imageName xPict


ImageOverlay('imageName',wData)

Form

ImageOverlay( x, wData, tBoxes )


Inputs

x                 Image file on initialization or text data
wData             Window name
.name   string
.color  [r g b]
tBoxes            Box positions

Outputs

none

◆ IMMPredict()

function IMMPredict ( in  d)

Interactive Multiple Models prediction step.

This does the interaction and filter steps. The inputs and outputs only show data structure fields used in this function. This assumes that the number and definitions of the state do not change. There are n models and m states. IMMUpdate is normally called after IMMPredict.

A complete IMM implementation is:

IMMPredict( d )
IMMUpdate( d )

Form

d = IMMPredict( d )


Inputs

d     (.)  IMM data structure
.use     (1,1)   'KF' 'EKF' 'UKF' Only KF is implemented
.pIJ     (n,n)   Model transition probability
.muI     (1,n)   Probability of being in that model
.mI      (m,n)   Means for each model
.pI      {n}     Covariance matrix for each model
.aI      {n}     State transition matrix for each model
.qI      {n}     Plant noise matrix for each model

Outputs

d   (.)  IMM data structure
.cHatJ    (1,n) Scaling factor
.mPI     (m,n)   Mean vectors for each model
.pPI     {n}     Covariance matrix for each model

◆ IMMUpdate()

function IMMUpdate ( in  d)

Interactive Multiple Models update step.

The inputs and outputs only show data structure fields used in this function.

All inputs are after the prediction of the state (see IMMPredict). IMMUpdate is called after IMMPredict. A complete IMM implementation is

IMMPredict( d ) IMMUpdate( d )


Form

d = IMMUpdate( d )


Inputs

d   (1,1)  IMM data structure
.use     (1,1)    'KF' 'EKF' 'UKF' Only KF is implemented
.cHatJ  (1,n)    Scaling factor
           .mPI     (m,n)    Mean vectors for each model

.pPI     {n}      Covariance matrix for each model
.y       (p,1)    Measurements
.h       (p,m)    Measurement matrix
.r       (p,p)    Measurement noise covariance

Outputs

d   (1,1)  IMM data structure
.m       (n,1)    Aggregate mean
.p       (n,n)    Aggregate covariance
.mI      (m,1)    Model mean
.pI      {n}(m,m) Model covariance

◆ InertiaFromOBJFile()

function InertiaFromOBJFile ( in  fileName,
in  mass,
in  scale,
in  c 
)

Computes an inertia matrix from an obj file or data structure.

The data structure is g.component(k).v.

Assigns a mass proportional to the patch area and the centroid.

Type InertiaFromOBJFile for a demo of an X-15.


Form

inr = InertiaFromOBJFile( fileName, mass, scale, c )


Inputs

fileName    (1,:) File name or data structure
mass        (1,1) Dry mass (kg)
scale       (1,1) Optional scale factor
c           (3,1) Optional center of mass  (m)

Outputs

inr         (3,3) Inertia matrix (kg-m^2)
c           (3,1) Center of mass (m)
area        (1,1) Surface area (m^2)

◆ Inertias()

function Inertias ( in  m,
in  x,
in  type,
in  ignoredArg 
)

Computes inertias of common objects about their c.m.

All objects have their axis of symmetry about z. If you enter a thickness with 'cylinder', 'box' or 'sphere' it will automatically compute the hollow versions.

The output is in the form:

[ixx iyy izz ixy ixz iyz]

If four arguments are entered it outputs a 3 by 3 matrix.


Form

inr = Inertias( m, x, type, matType )


Inputs

m             (1,1) Mass
x                   Relevant dimensions
type                Type of solid
'sphere'          x = [radius]
'box'             x = [xLength, yLength, zLength]
'plate'           x = [xLength, yLength]
'disk'            x = [radius]
'cylinder'        x = [radius, zLength] 
'ellipsoid'       x = [a b c]
'hollow cylinder' x = [outer radius, zLength, thickness]
'hollow box'      x = [xLength, yLength, zLength, thickness]
'hollow sphere'   x = [radius, thickness]
matType       (1,1) Any argument causes the routine to return a 3x3 matrix

Outputs

inr     (1,6)   Inertia matrix

◆ Inflation()

function Inflation ( in  from,
in  to 
)

Computes U.S.

inflation.

Type Inflation for a demo.

Form

i = Inflation( from, to )


Inputs

from        (1,1) Year from
to          (1,1) Year to

Outputs

i           (1,1) Fraction inflation

◆ InformDlg()

function InformDlg ( in  text,
in  title 
)

Create an information dialog that will be dismissed by a script.

Similar to msgbox but without a button. The text will be wrapped. The HandleVisibility of this figure is 'callback'. Use 'close all hidden' to delete figure in the case of errors.

Type InformDlg for a demo.


Form

[figureHandle,msgHandle] = InformDlg( text, title )


Inputs

text           (:)     Text of the message.
title          (:)     Title of the message box.

Outputs

figureHandle   (1,1)    Handle of figure.
msgHandle      (1,1)    Handle to message string control.

◆ Integral()

function Integral ( in  Kdc,
in  w,
in  phase,
in  tSamp,
in  sType 
)

Creates a general integrator.

Creates a general integrator of the form


tau s + 1
K(s) = ----------
s + sigma


Given the desired maximum phase magnitude (±90°) and frequency


Type Integral for a demo.

Form

[a, b, c, d] = Integral( Kdc, w, phase, tSamp, sType )


Inputs

Kdc                 DC gain (db)
w                   Frequency for phase (rad/sec)
phase               Phase angle (-90° to 0°) (deg)
tSamp               Sampling period
sType               State equation type ('Delta' or 'Z')

Outputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Feedthrough matrix

◆ IntersectPlaneAndSphere()

function IntersectPlaneAndSphere ( in  r,
in  plane,
in  n 
)

Finds the vector giving the intersection.

of a plane and a sphere.

The normal is

n = ai + bj + ck

The equation of the plane is

a(x-x1) + b(y - y1) + c(z - z1) = 0

where [x1;y1;z1] is a point in the plane.

For example, the xy-plane is

z = 0 which is generated by a = 0, b = 0, c = 1 and [x1;y1;z1] = [dont care;dont care;0].

If no input arguments are entered it will generate a random plane. If no output arguments are specified it will plot the intersection.


Form

v = IntersectPlaneAndSphere( r, plane, n )


Inputs

r          (1,1)   Radius of sphere
plane      (1,1)   Data structure for plane
.n   (3,1) Normal
.x   (3,1) Point in the plane
n          (1,1)   Half the number of points on the equation of
the intersection ellipse. The default is 50.

Outputs

v          (:)     Data structure
.x         (3,n) Coordinates of the intersection
.intersect (1,1) 1 if the plane intersects the sphere

◆ IntToBinary()

function IntToBinary ( in  i)

Converts an integer to binary [lsb msb] in two's complement.


Form

b = IntToBinary( i )


Inputs

i            (1,1) Integer

Outputs

b            (1,:) Binary array [lsb, msb]

◆ InvSys()

function InvSys ( in  a,
in  b,
in  c,
in  d 
)

Computes the inverse system.

Computes the inverse system where y is the input and u the output.


Form

[ai, bi, ci, di] = InvSys( a, b, c, d )



Inputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix

Outputs

ai                  Inverse plant matrix
bi                  Inverse input matrix
ci                  Inverse measurement matrix
di                  Inverse input feedthrough matrix

References: Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, pp. 376-378.


Since version 1.


◆ IsFunction()

function IsFunction ( in  filename)

Determine whether a file is a function or script.


Form

state = IsFunction ( fileName)


Inputs

fileName     (1,:)     File name

Outputs

state            (1,1)     not a function (0), is a function (1)

◆ IsValidField()

function IsValidField ( in  m,
in  s 
)

Determine if a field exists and is not empty.


Form

x = IsValidField( m, s )


Inputs

m     (1,1) Structure
s     (1,:) Field

Outputs

x     (1,1)  1 = true

◆ IsVersionAfter()

function IsVersionAfter ( in  n)

Checks to see if the version of MATLAB is after n.


Form

t = IsVersionAfter( n )


Inputs

n             (1,1)   Number

Outputs

t             (1,1)   1 or 0

◆ IsVersionBefore()

function IsVersionBefore ( in  n)

Checks to see if the version of Matlab is before n.


Form

t = IsVersionBefore( n )


Inputs

n             (1,1)   Number

Outputs

t             (1,1)   1 or 0

◆ JD2000()

function JD2000 ( )

Returns the Julian Date for J2000.0 0d 0h UT.


Form

jD = JD2000


Inputs

None

Outputs

jD      (1,1) Julian date

◆ JD2Array()

function JD2Array ( in  jD0,
in  t 
)

Compute an array of Julian dates from an epoch.


Forms: jD = JD2Array( jD0, t )



Input

jD0   (1,1)    Epoch Julian date
t     (1,:)    Time array (sec)

Output

jD    (1,:)    Julian date array

◆ JD2Date()

function JD2Date ( in  jd,
in  structOut 
)

Compute the calendar date from the Julian date.

Uses the format from clock. If no inputs are given it will output the current date and time of the function call.


Form

datetime = JD2Date( jd, structOut )


Inputs

jd           (1,1)  Julian date
structOut    (1,1)  If entered, output a structure

Outputs

datetime     (1,6)  [year month day hour minute seconds]

References: Montenbruck, O., T.Pfleger, Astronomy on the Personal Computer, Springer-Verlag, Berlin, 1991, p. 13.


◆ JD2Day()

function JD2Day ( in  jD)

Computes the day of the week from Julian day number.

Typing JD2Day returns the current date.


Form

day = JD2Day( jD )


Inputs

jD           (1,1) Julian date

Outputs

day          (1,3) 'Sun' 'Mon' 'Tue' 'Wed' 'Thu' 'Fri' 'Sat'

References: Meeus, J. "Astronomical Algorithms". p.65.


◆ JD2DN()

function JD2DN ( in  jD)

Compute the day number from Julian date.

Typing JD2DN returns the current day number.


Form

dayNumber = JD2DN( jD )


Inputs

jd            (1,1) Julian date

Outputs

dayNumber     (1,1) Day number
year          (1,1) Year

◆ JD2MJD()

function JD2MJD ( in  jD)

Converts Julian date to Modified Julian Date.

Typing JD2MJD returns the current MJD.


Form

mJD = JD2MJD( jD )


Inputs

jD           Julian date (days)

Outputs

mJD          Modified Julian date (days)

Reference: The Astronomical Almanac for the Year 1993, U.S. Government Printing Office,1993, p. B4.


◆ JD2T()

function JD2T ( in  jd)

Converts Julian days to centuries from J2000.0.

Typing JD2T returns the current Julian century.


Form

T = JD2T( jd )


Inputs

jd           (1,:) Julian date (days)

Outputs

T            (1,:) Julian centuries of 86400s dynamical time from j2000.0

◆ JDToDateString()

function JDToDateString ( in  jD,
in  ignoredArg 
)

Convert Julian Date to the form '04/20/2000 00:00:00'.

If calForm is entered you will get Apr 20, 2000

Typing JDToDateString returns the current date.


Form

s = JDToDateString( jD, calForm)


Inputs

jD      (1,1)   Julian Date   
calForm (1,1)    'mm/dd/yyyy hh:mm:ss'

Outputs

s       (1,:)   String 'mm/dd/yyyy hh:mm:ss' or 'Jan dd, yyyy'

◆ JDToMidnight()

function JDToMidnight ( in  jD)

Converts a Julian date to the nearest midnight.


Form

jDMid = JDToMidnight( jD )


Inputs

jD           (:)  Julian date

Outputs

jDMid        (:)  Julian midnights

◆ JLQOF()

function JLQOF ( in  k,
in  g,
in  w,
in  x 
)

Linear quadratic regulator with an output feedback cost function.


Form

j = JLQOF( k, g, w, x )


Inputs

k                      Gain
g                      State space data structure
w                      Weighting matrix
x                      States

Outputs

j                      Scalar cost

◆ JLQTOF()

function JLQTOF ( in  k,
in  g,
in  w,
in  t 
)

Output feedback design with a reference input.

dx/dt = ax + bu + gr
y = cx + fr
z = hx        (Performance criteria)

Form

j = JLQTOF( k, g, w, t )


Inputs

k                      Gain
g                      State space data structure
w                      Weighting matrix
t                      Tracking matrices data structure

Outputs

j                      Scalar cost

◆ JLQTWOF()

function JLQTWOF ( in  k,
in  g,
in  w,
in  t,
in  options 
)

Output feedback design with a reference input.

dx/dt = ax + bu + gr
y = cx + fr
z = hx        (Performance criteria)


The performance index is
J = † (t^k *x'*P*x + x'*Q*x) dt


options(1) = 1 add control to t^k term
else add to Q


options(2) = 1 tracker problem
else regulator problem

Form

j = JLQTWOF( k, g, w, t, options )


Inputs

k                      Gain
g                      State space data structure
w                      Weighting matrix
t                      Tracking matrices data structure
options       (1,2)    Algorithm options
options(1) = 1 Multiply the control weighting by t^k
options(1) = 0 Multiply the control weighting by 1
options(2) = 1 Tracker problem
options(2) = 0 Regulator problem

Outputs

j                      Scalar cost

◆ KalmanFilterCombine()

function KalmanFilterCombine ( in  xB,
in  pB,
in  xF,
in  pF 
)

Combine forward and backward covariances and states.


Form

[xS, pS] = KalmanFilterCombine( xB, pB, xF, pF )


Inputs

xB        (n,1)  Backward state
pB        (n,n)  Backward covariance
xF        (n,1)  Forward state
pF        (n,n)  Forward covariance

Outputs

xS        (n,1)  Smoothed state
pS        (n,n)  Smoothed covariance

References: R.G. Brown and P.Y.C. Hwang. Introduction to Random Signals and Applied Kalman Filtering, 2nd Edition. John Wiley and Sons, 1992.


◆ KFilter()

function KFilter ( in  r,
in  phi,
in  q,
in  h,
in  x,
in  z,
in  p,
in  gamma,
in  u,
in  s 
)

Mechanizes one step of a Kalman Filter with a forgetting factor.

x[k+1] = phi*x[k] + gamma*u[k] y[k] = x[k] + k[k]*(z - h*x[k])

The forgetting factor scales the covariance factor in the covariance update. If it were zero the covariance update would be the state covariance matrix q.

p = s*phi*p*phi' + q;

The function automatically forces symmetry on p by averaging p and p'.

The function handles deterministic inputs as shown above. gamma is optional so it will also handle x[k+1] = phi*x[k] + u[k].

Note that the matrices are for a discrete time system.


Form

[x, p, k, y, pY] = KFilter( r, phi, q, h, x, z, p, gamma, u, s )


Inputs

r (m,m) Measurement Covariance phi (n,n) State transition matrix q (n,n) Process noise covariance h (m,n) Measurement matrix x (n) Previous value of the state z (m) Measurement vector p (n,n) Covariance of xold gamma (n,l) Input matrix u (n) Deterministic input s Forgetting factor 1 = don't, ƒ = 1 stage filter


Outputs


x         (n)    Updated state this is at time k+1
p         (n,n)  Covariance of x 
k         (n,m)  Kalman Gain matrix
y         (m,1)  Output at time k
pY        (n,n)  Covariance after the measurement update

◆ KFInitialize()

function KFInitialize ( in  type,
in  varargin 
)

Initializes Kalman Filter data structures for the KF, UKF, EKF and IEKF.

Enter parameter pairs after the type.

If you return with only one input it will return the default data structure for the filter specified by type. Defaults are returned for any parameter you do not enter.


Form

d = KFInitialize( type, varargin )


Inputs

type           (1,1) Type of filter 'ukf', 'kf', 'ekf', 'iekf'
varargin       {:}   Parameter pairs

Outputs

d              (1,1) Data structure

◆ KFPredict()

function KFPredict ( in  varargin)

Linear Kalman Filter prediction step.

This assumes a discrete model of the form:

x[k] = a[k-1]x[k-1] + b[k-1]u[k-1] + q y[k] = h[k]x[k] + r

b and u are optional.

If only one argument is entered it assumes it is a datastructure of the form d = struct('m',m,'p',','a',a,'q',q,'b',b,'u',u) or d = struct('m',m,'p',','a',a,'q',q,'bU',b*u)


Form

[m, p] = KFPredict( d )
[m, p] = KFPredict( m, p, a, q, b*u )
[m, p] = KFPredict( m, p, a, q, b, u );


Inputs

m             (n,1)  Mean
p             (n,n)  Covariance matrix
a             (n,n)  State transition matrix
q             (n,n)  Model noise matrix
b             (n,p)  Deterministic input matrix
u             (p,1)  Deterministic input vector

Outputs

m             (n,1)  Mean
p             (n,n)  Covariance matrix

◆ KFUpdate()

function KFUpdate ( in  varargin)

Linear Kalman Filter measurement update step.

This assumes a discrete model of the form:

x[k] = a[k-1]x[k-1] + b[k-1]u[k-1] y[k] = h[k]x[k]

All inputs are after the predict state (see KFPredict). The Kalman filter can be initialized using KFInitialize. This routine can use the data structure form of the measurement where the measurement is in y.data.

The inputs can be individual matrices or as part of a data structure. The data structure is d = struct('m',m,'p',p,'y',y,'h',h,'r',r);

All Kalman Filter routines accept data structures.


Forms: d = KFUpdate( d ) [m,p,v,s,k] = KFUpdate( m, p, y, h, r )



Inputs

m             (n,1)  Mean vector
p             (n,n)  Covariance matrix
y             (m,1)  Measurement vector
h             (m,n)  Measurement matrix
r             (m,m)  Measurement noise matrix

Outputs

m             (n,1)  Mean vector
p             (n,n)  Covariance matrix
v             (n,n)  Residual vector
s             (n,n)  Covariance denominator
k             (n,n)  Kalman gain matrix

◆ KronProd()

function KronProd ( in  a,
in  b 
)

Compute the Kronecker product.


Form

c = KronProd( a, b )


Inputs

a             (m,n)  Matrix
b             (p,q)  Matrix

Outputs

c             (mp,nq) Kronecker product

References: Zhou, K., et. a. Robust and Optimal Control, Prenctice-Hall, 1996, p. 25.


◆ KronSum()

function KronSum ( in  a,
in  b 
)

Compute the Kronecker sum.


Form

c = KronSum( a, b )


Inputs

a             (n,n)  Matrix
b             (m,m)  Matrix

Outputs

c             (nm,nm) Kronecter Sum

References: Zhou, K., et. a. Robust and Optimal Control, Prenctice-Hall 1996, p. 25.


◆ KSmooth()

function KSmooth ( in  r,
in  phi,
in  q,
in  h,
in  z,
in  pI 
)

Mechanizes a Kalman Filter fixed interval smoother.

You input a full
set of measurements and it outputs the smoothed results.


Inputs

r (m,m) Measurement Covariance phi (n,n) State transition matrix q (n,n) Process noise covariance h (m,n) Measurement matrix z (m,:) Measurement vector p (n,n) Initial covariance


Outputs


xS        (n,:)    Filtered state
pDiag     (n,:)    Covariance diagonal

◆ LabelLine()

function LabelLine ( in  x,
in  t,
in  n,
in  f 
)

Labels a line.

x must have at least 2 rows. The format string is any standard matlab format such as 't = %12.4f'


Form

LabelLine( x, t, n, f )


Inputs

x          (2,:)   [x;y]
t          (1,:)   Numbers for labels
n          (1,1)   Number of labels
f          (1,:)   Format string

Outputs

None

◆ LabelS()

function LabelS ( in  x,
in  y,
in  z,
in  font 
)

Creates 2 or 3 axis labels.


Form

LabelS( x, y, z, font )


Inputs

x      (1,:) X label
y      (1,:) Y label
z      (1,:) Z label, may be empty for 2D
font   (1,:) Font name

Outputs

None

◆ LatexExp()

function LatexExp ( in  n,
in  f 
)

Creates a latex exponential string.

Converts a number like 1.2e3 in 1.2$\times 10^{3}$.

Type LatexExp for a demo.

See also LatexScientificNotation.


Form

s = LatexExp( n, f )


Inputs

n     (1,1) Number
f     (1,:) Exponential format (don't include the e)

Outputs

s     (1,:) Latex string

Copyright (c) 2017 Princeton Satellite Systems, Inc. All rights reserved.


Since version 2018.1 2020.1 Added default for f


◆ LatexScientificNotation()

function LatexScientificNotation ( in  x,
in  n,
in  m 
)

Converts a number into a string using latex notation.

Type LatexScientificNotation for a demo.

See also LatexExp.

Form

s = LatexScientificNotation( x, n, m )


Inputs

x        (1,1)  Number
n        (1,1)  Number of decimal digits
m        (1,1)  Number of significant digits

Outputs

s        (1,:)  Latex string

◆ LatexTableFromStructure()

function LatexTableFromStructure ( in  s,
in  f,
in  u 
)

Creates a LaTeX table from s.

It searches the data structure recursively so that each column is
a field name. The final column has numbers.
u has the same structural form as s but rather than numbers each
value is a units array. For example


s.a   = 1;
s.b.q = 2;
s.b.r = 3;


has a corresponding u


u.a   = 'rad';
u.b.q = 'N';
u.b.r = 'm';


Type LatexTableFromStructure for a demo.

Form

x = LatexTableFromStructure( s, f, u )


Inputs

s               (1,1) Data structure
f               (1,:) File name
u               (1,1) Data structure of units

Outputs

x               {:,:} The cell array

◆ LeadLag()

function LeadLag ( in  wmax,
in  phasemax,
in  Kdc,
in  tSamp,
in  sType 
)

Create a lead or lag.

Create a lead or lag with the appropriate phase characteristics in the form

tau1 s + 1
K(s) = Kdc ----------
tau2 s + 1


Given the desired maximum phase magnitude (±90°) and frequency

Form

[a, b, c, d] = LeadLag( wmax, phasemax, Kdc, tSamp, sType )


Inputs

wmax                  Frequency for max (rad/sec)
phasemax              Max phase angle (deg)
Kdc                   DC gain (db)
tSamp                 Sampling period
sType                 State equation type ('Delta' or 'Z')

Outputs

a                     Plant matrix
b                     Input matrix
c                     Measurement matrix
d                     Feedthrough matrix

◆ LeapYear()

function LeapYear ( in  datetime)

Determines if a year is a leap year.

Typing LeapYear returns the current leap year.


Form

ly = LeapYear( datetime )


Inputs

datetime    (1,6) [year month day hour minute seconds] or just year

Outputs

ly          (1,1) 1 = yes, 0 = no

◆ LegendFig()

function LegendFig ( in  names,
in  colors,
in  figTitle 
)

Produce a new figure with just a legend of colors and names.


Form

h = LegendFig( names, colors, title )


Inputs

names         {1,n}    Cell array of names to go in the legend
colors        {1,n}    Cell array of 1-character colors 
-or-  (n,3)    n rows of 3-element color vectors 


figTitle      (1,:)    Title for new legend figure. Optional.

Outputs

h             (1,1)    Figure handle.


See also:  ColorSpread.m

◆ LegendTitle()

function LegendTitle ( in  name,
in  size 
)

Add a title to the current legend.

The title will be bold. The default font size is 12.


Form

LegendTitle( name, size )


Inputs

name  (1,:)    Title
size  (1,1)    Fontsize

Outputs

None

See also LegendWithTitle


◆ LegendWithTitle()

function LegendWithTitle ( in  s,
in  title,
in  varargin 
)

Create a legend with a title.

legend uses 'tex' as the interpreter so you can pass it latex commands in s or in title.


Form

LegendWithTitle( s, title, varargin )


Inputs

s         {:}   Legend entries
title     (1,:) Title
vararagin {:}   Parameter pairs passed to legend

Outputs

None

◆ LFBal()

function LFBal ( in  g,
in  gamma 
)

Perform low frequency prebalancing of a system.


Form

g = LFBal( g, gamma )


Inputs

g           (:)   Plant model of type statespace
gamma       (1,1) Value of all singular values of g(0)

Outputs

g           (:)   Augmented plant

Reference: Stevens, B.L., Lewis, F.L. Aircraft Control and Simulation John Wiley & Sons, 1992, pp. 466-469.


◆ Limit()

function Limit ( in  x,
in  limit 
)

Limits a matrix.

If limit is a scalar then the limits are set at plus or minus the 
limit.

Form

x = Limit( x, limit )


Inputs

x                      Vector to be quantized
limit          (2)     Limit values [max,min]

Outputs

x                      x limited to be between the limits.

◆ ListCases()

function ListCases ( in  filename,
in  beQuiet,
in  first 
)

List the switch cases that are included in a given file.

The default is to print the full set of case names to the command line as well as provide an output. To suppress the command line display pass true for quiet.


Form

names = ListCases( filename, beQuiet, first )


Inputs

filename      (:)    String name of file to examine
beQuiet       (1)    Flag for quiet operation - no printout
first         (1)    Flag to keep only first case for a cell array 

Outputs

names         {:}   Cell array of case names

◆ ListFunctions()

function ListFunctions ( in  filename,
in  level,
in  noMatlabFuns,
in  method 
)

List the functions that are called from a given file.

All functions located under the matlabroot directory are ignored, because they are assumed to be built-in MATLAB functions.

If no filename is provided, the file "PIDMIMO" is used as an example.


Form

[names,dirs,exts] = ListFunctions( filename, level, noMatlabFuns, method )


Inputs

filname       (:)    String name of file to examine
level         (1)    How many levels to search (-1 fully recursive, 
1 for 'toponly')
noMatlabFuns  (1)    Flag - exclude MATLAB functions (1) or not (0)
method        (1)    Use "profile" or "depfun". Default is "depfun".

Outputs

names         {:}   Cell array of function names
dirs          {:}   Cell array of corresponding directory names
exts          {:}   Cell array of extensions

◆ ListMemberFunctions()

function ListMemberFunctions ( in  filename,
in  verbose 
)

List the member functions that are included in a given function/file.


Form

names = ListMemberFunctions( filename, verbose )


Inputs

filname       (:)    String name of file to examine
verbose       (1)    Print results (1) or not (0). Default is verbose.

Outputs

names         {:}   Cell array of member function names
lines         {:}   Cell array of member function definition lines

◆ ListParents()

function ListParents ( in  fcn,
in  folder,
in  recursive 
)

List all parents of a function.

Search inside given folder.


Form

[parents,lineNums,lines] = ListParents( fcn, folder, recursive )


Inputs

fcn          (1,:)   String name of file to examine
folder       (1,:)   Folder name to search in. Can be a single name
or cell array of names. Each name must have the
full path included.
recursive    (1,1)   Recursive flag. 
1- search in all sub folders (default)
0- search only in given folder

Outputs

parents         {:}   Cell array of parent function names
lineNums        {:}   Cell array of line no.s in each parent function
where child "fcn" is called.
lines           {:}   Cell array of lines in each parent function where
child "fcn" is called.

◆ LoadSimLog()

function LoadSimLog ( in  file)

Reads data from a simulation log file.

If file is not entered it will display a file selection dialog box. Also see PlotDSimFile which handles component logs.


Form

[x, v, r, s, t, d] =  LoadSimLog( file )


Inputs

file           (1,:)  File name

Outputs

x              (n,:) Data each row is a time step
v              {m}   Names for each column. ":" replaced with "_"
r              {m}   Indices in x for each variable.
s              {m}   Native size for each variable
t              (1,n) MET of entries
d              (.)   Data structure with Time and fields for all data
using the names in v

Sample file data:

Time,"-2 SC:rWARate","-2 SC:angularMomentum"
0.1,"[0.9999840718;2.000001976;3.000008952;3.999997113]","[1000.049761;-999.9602393;2000.079761]"

◆ Loc3D()

function Loc3D ( in  p,
in  u,
in  cM 
)

Plot the location of points.


Form

Loc3D( p, u, cM )


Inputs

p          (3,n)  Location of n points
u          (3,n)  Unit vectors for the points
cM         (3,1)  System cm (optional)

Outputs

None

◆ LocalTimeToGMT()

function LocalTimeToGMT ( in  dateTime,
in  lon 
)

Compute the Julian Date from the local time.

This does not handle daylight savings time, etc.


Form

jD = LocalTimeToJD( dateTime, lat, lon )


Inputs

datetime      (1,6) [year month day hour minute seconds]
or the datetime data structure.
.year
.month                             
.day                             
.hour                             
.minute                             
.second
lon           (1,1)  Longitude in radians

Outputs

datetimeGMT    (1,6) [year month day hour minute seconds]
or the datetime data structure.
.year
.month                             
.day                             
.hour                             
.minute                             
.second
jD             (1,1) Julian date 

◆ LocalTimeToJD()

function LocalTimeToJD ( in  dateTime,
in  lon 
)

Compute the Julian Date from the local time.

This does not account for daylight savings time.


Form

jD = LocalTimeToJD( dateTime,  lon )


Inputs

datetime      (1,6) [year month day hour minute seconds]
or the datetime data structure.
.year
.month                             
.day                             
.hour                             
.minute                             
.second
lon           (1,1)  Longitude in radians

Outputs

jD            (1,1) Julian date

◆ LogB()

function LogB ( in  b,
in  x 
)

Log base b.

Either x or b can be a vector.


Form

y = logB(b,x)


Inputs

b   (1,:)   Base
x   (1,:) Value

Outputs

y   (1,:)   log(x) base b

Copyright (c) 2017 Princeton Satellite Systems, Inc. All rights reserved.


Since version 2018.1 2019.1 Allows it to handle vector iputs


◆ LogLimit()

function LogLimit ( in  wV)

Given a frequency vector, find the logarithm of the frequency.

limits that span the set.


Form

[logWMin, logWMax] = LogLimit( wV )


Inputs

wV          Frequency vector

Outputs

logWMin     Log of the minimum frequency
logWMax     Log of the maximum frequency

◆ LQC()

function LQC ( in  g,
in  w,
in  type,
in  t 
)

Design a quadratic controller.


Form

[gC, j] = LQC( g, w, type, t )


Inputs

g             (:)     Plant of type statespace
w             (:)     Weighting matrices depends on the type of design
-------------------------------
w.q   : lq, lqe, lqg, all ...of,  lqgltri
w.r
w.k  (optional initial stabilizing gain for of)
w.n  (optional)
-------------------------------
w.b  : lqe
-------------------------------
w.qE  : lqg, lqgtro
w.rE
w.bE (optional)
w.nE (optional)
w.w  (optional) Frequencies for sv plots
-------------------------------
w.rho : lqgltri or lqgltro
w.q0
w.gLow   robustness low frequency limit
w.gHigh  robustness low frequency limit
type      (1,:)   Type of design
'lq'      Full state feedback
'lqe'     Estimator
'lqg'     Full state feedback with estimator
'lqof'    Linear quadratic with output feedback
'lqtof'   Linear quadratic tracker with output feedback
'lquwof'  Time weighted control linear quadratic with output feedback
'lqtuwof' Time weighted control linear quadratic tracker with output feedback
'lqxwof'  Time weighted state linear quadratic with output feedback
'lqtxwof' Time weighted state linear quadratic tracker with output feedback
'lqgltri' Full state feedback with estimator and loop
transfer recovery at the input
'lqgltro' Full state feedback with estimator and loop
transfer recovery at the output
t           (:)     Tracking model
.r
.g
.h

Outputs

gC        (:)     Controller of type statespace
j       (:)     .initial
.final

◆ LQPlugIn()

function LQPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create an LQ plug in for the ControlDesignGUI.

Typing LQPlugIn is the same as LQPlugIn('initialize')


Form

x = LQPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ MagPlot()

function MagPlot ( in  a,
in  b,
in  c,
in  d,
in  iu,
in  iy,
in  w 
)

Compute the magnitude frequency response of a system.s.

Compute the magnitude frequency response of the system x = ax + bu y = cx + du

for the input vector iu, and output vector iy. If no output arguments
are given it will automatically display Bode plots for all channels.

Form

[mag, io, w] = MagPlot( a, b, c, d, iu, iy, w )
[mag, io, w] = MagPlot( num, den, w )


Inputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix
iu                  Inputs  ( = 0, or [] for all)
iy                  Outputs ( = 0, or [] all)
w                   Frequency vector

Outputs

mag                 Magnitude vector
io                  Input/output vector per plot [input,output;...]
w                   Frequencies computed

◆ Map()

function Map ( in  planet,
in  mType,
in  ignoredArg 
)

Draws a 2 or 3 dimensional map of a planet.

Turns on mouse driven 3D rotation if mType == '3d'. String inputs are not case sensitive. planet is the name of a .mat file with the variables planetMap and planetColorMap.

You generate the planet data structure like this example for a gray scale image of Pluto; the replication of the image map is needed because the png is gray scale.

p = imread('pluto.png');
p3(:,:,1) = p;
p3(:,:,2) = p;
p3(:,:,3) = p;
planet.planetMap = p3;
planet.radius = Constant('equatorial radius pluto');
planet.name = 'Pluto';

The planetColorMap is not needed if the planetMap is true color, with channels for R, G, B (m x n x 3).

The radius field may be an array of semimajor axes, (1x3). See Ellipsd.


Form

p = Map( planet, mType, noNewFig )


Inputs

planet        (1,:)    Any planet mat-file name or the structure
planet.planetMap
planet.planetColorMap
planet.radius
mType         (2,:)   '2d' or '3d', default is '3d'
noNewFig      (1,1)    If entered, don't create a new figure.

Outputs

p             (.)      Planet image data structure

◆ MapIOPlugIn()

function MapIOPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create an MapIO plug in for the ControlDesignGUI.


Form

x = MapIOPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ MassPressureVessel()

function MassPressureVessel ( in  d,
in  t,
in  rho,
in  type 
)

Computes the mass of a pressure vessel.

Cylindrical vessels include a spherical cap. The default type is 'cylinder'.

Type MassPressureVessel for a demonstration of a 0.2 m and 1.0 m long pressure vessel made of titanium.


Form

m = MassPressureVessel( d, p, sigma, type )


Inputs

d        (1,1) Radius for sphere [radius length] for cylinder (m)
t        (1,:) Thickness (mm)
rho      (1,1) Density
type     (1,:) 'cylinder' or 'sphere'

Outputs

m        (1,:) Mass (kg)

◆ MassProp()

function MassProp ( in  inr,
in  m,
in  cM,
in  u,
in  cName,
in  c 
)

Compute inertia, mass and center of mass for a collection of rigid bodies.

If no output is specified it will print the results. The cm's must be given in the core frame but the inertias may be given in their own frame and the transformation from the component frame to the core frame given in c.


Form

[inrT, mT, cMT, inrP, cP] = MassProp( inr, m, cM, u, cName, c )


Inputs

inr         (6,:)   Inertia matrices. Each column is [Ixx;Iyy;Izz;Ixy;Ixz;Iyz]
Ixy,Ixz and Iyz may be omitted for all bodies.
m           (1,:)   Masses
cM          (3,:)   Center of masses. Each column is [x;y;z]
u           (3,1)   Units 'sgF' = slug-ft^2, 'sgI' = slug-in^2, 'mks' = metric
'inL' = in-lbf-sec^2;
cName       (:,:)   Component name
c           (9,:)   Transformation matrices. Each column is [c(:,1);c(:,2);c(:,3)];
Transforms from the core frame to the element frame

Outputs

inrT        (3,3)   Inertia matrix
mT          (1,1)   Mass
cMT         (3,1)   Center of mass
inrP        (3,3)   Inertia matrix in principal axes
cP          (3,3)   Transformation matrix from core to principal axis
such that inrP = cP'*inrT*cP

◆ MassPropertiesSolidObjFile()

function MassPropertiesSolidObjFile ( in  fileName,
in  mass,
in  scale 
)

Computes a mass properties data structure from an obj file.

This assumes that the solid is simple without holes.

Type MassPropertiesSolidObjFile for sphere and box examples.


Form

[m, vol] = MassPropertiesSolidObjFile( fileName, mass, scale )


Inputs

fileName    (1,:)   File name or data structure
mass        (1,1)   Mass (default is 1)
scale       (1,1)   Scale factor

Outputs

m           (1,1)   Mass data structure
.mass    (1,1) Mass
.cM      (3,1) Center-of-mass
.inertia (3,3) Inertia matrix
vol         (1,1)   Volume

◆ MassPropertiesTetrahedron()

function MassPropertiesTetrahedron ( in  v,
in  rho 
)

Compute inertia, volume and center of mass of a uniform tetrahedron.

Type MassPropertiesTetrahedron for a demo


Usage: [m, vol] = MassPropertiesTetrahedron( v, rho )



Inputs

v           (3,4)   Edge vectors
rho         (1,1)   Density

Outputs

m           (1,1)   Mass data structure
.mass    (1,1) Mass
.cM      (3,1) Center-of-mass
.inertia (3,3) Inertia matrix
vol         (1,1)   Volume

Reference: R. Baber, "Rigid Body Simulation," August 2006, pp 13-15.


◆ MassStructure()

function MassStructure ( in  mass,
in  type,
in  info,
in  cM 
)

Create a mass data structure.


Form

m = MassStructure( mass, type, info, cM )
m = MassStructure( mass, inr, cM )


Inputs

mass           (1,1)   Mass
type           (1,:)   Type of body or (3,3) Inertia matrix
info           (:,:)   Dimensions depends on type see Inertias
cM             (3,1)   Center-of-mass location

Outputs

m              (1,1)   Structure
.mass     (1,1) mass
.inertia  (3,3) Inertia matrix
.cM       (3,1) Center of mass

◆ Mat2Eul()

function Mat2Eul ( in  m,
in  e 
)

Converts an orthonormal transformation matrix into 3-2-1 Euler angles.

Uses the input e(1) for e(1) near the singularity.

Form

e = Mat2Eul( m, e ) 


Inputs

m       (3,3)  Orthonormal transformation matrix
e       (3,1)  Euler angles

Outputs

e       (3,1)  Euler angles

◆ Mat2Q()

function Mat2Q ( in  m)

Converts a transformation matrix to a quaternion.

Does not check to see that m is orthonormal.


Form

q = Mat2Q ( m )     


Inputs

m       (3,3)  Orthonormal transformation matrix

Outputs

q       (4,1)  Equivalent quaternion

References: Shepperd, S. W., Quaternion from Rotation Matrix, J. Guidance, Vol. 1, No. 3, May-June, 1978, pp. 223-224.


◆ MatrixCellTo3D()

function MatrixCellTo3D ( in  c)

Convert a cell array of p x p matrices into a 3D matrix.


Form

m = MatrixCellTo3D( c )


Inputs

c             {n}       Cell array of m x m matrices

Outputs

m             (p,p,n)   3D matrix

◆ MatrixDisplay()

function MatrixDisplay ( in  x,
in  f 
)

Display a matrix using the format f.

f is a string like '%12.4f'

Type MatrixDisplay for a demo.


Form

MatrixDisplay( m, f )


Inputs

x              (:,:)  Matrix
f             (1,:)  Format

Outputs

Displays to the command line

◆ MatToCell()

function MatToCell ( in  m)

Converts a string matrix to a cell array.


Form

c = MatToCell( m )


Inputs

m         (:)   String matrix

Outputs

c           {}    One dimensional cell array of strings

◆ MeasNLSpring()

function MeasNLSpring ( in  x,
in  d 
)

Computes nonlinear spring measurement.

The measurement is the arctangent of x/d.w


Form

y = MeasNLSpring(x,d)


Inputs

x       (2,1)   State [x;v]
d        (.)  Data structure
.w (1,1) Baseline 

Outputs

y       (1,1)   Measurement

◆ MeasPartialNLSpring()

function MeasPartialNLSpring ( in  x,
in  d 
)

Computes nonlinear spring measurement partial derivative.


Form

y = MeasPartialNLSpring(x,d)


Inputs

x       (2,1)    State [x;v]
d        (.)   Data structure
.w

Outputs

dY     (1,2)    Measurement

◆ MeasSpring()

function MeasSpring ( in  x,
in  ignoredArg 
)

Spring measurement.

The measurement simply equals the distance x.


Form

y = MeasSpring( x, ~ )


Inputs

x         (1,1) State

Outputs

y         (1,1)  Measurement

◆ MergeConstantDB()

function MergeConstantDB ( in  action,
in  a,
in  b 
)

Merges b into a using a GUI.

The new file is saved as "NewDB.mat".


Form

MergeConstantDB( action, a, b )


Inputs

action        (1,:)    Action to be taken
a             (1,:)    Database to be merged and merged project
b             (1,:)    Database to be merged

Outputs

h              (:)     GUI struct

Referenced by CreateGUI().

◆ Mesh2()

function Mesh2 ( in  xCol,
in  yRow,
in  z,
in  xLbl,
in  yLbl,
in  zLbl,
in  figTitle 
)

Draws mesh plots with axis labels.

If either xCol or yRow are a scalar, draws a 2 dimensional plot. Rows of z are y and columns are x. An example:

x = 1:10;
y = 1:20;
z = y'*x;
Mesh2(x,y,z,'X','Y','Z')

Form

hFig  = Mesh2( xCol, yRow, z, xLbl ,yLbl, zLbl, figTitle )


Inputs

xCol                Column Indices
yRow                Row indices
z                   Z values
xLbl                X label
yLbl                Y label
zLbl                Z label
title               figTitle

Outputs

hFig   (1,1) Figure handle

◆ Mesh3DMF()

function Mesh3DMF ( in  v,
in  vM,
in  fileName,
in  colorAtt 
)

Generate a 3DMF file for a mesh.

This function will append ".t3d" to the file.

The vertices in the vertex list must be in order, for example if the following are the vertices of a rectangle

1     2


4     3

they must be entered as [1;2;3;4]. colorAtt is vertex color information. One column vector is entered per vertex. The column vector is composed of

[ RGBDiffuse; RGBSpecular; SpecularExponent; RGBTransparency]

Each RGB variable is a column vector [r;g;b] where r,g and b are between 0 and 1. SpecularExponent is > 1 and can be large.


Form

Mesh3DMF( v, vM, fileName, colorAtt )


Inputs

v             (3,:)   Vertices
vM            (:,:)   Vertex map. Must be in order.
fileName      (:)     Filename
colorAtt      (10,:)  Color information [[r;g;b];[r;g;b];e;[r;g;b]]

Outputs

None

◆ MeshEllipsoid()

function MeshEllipsoid ( in  a,
in  b,
in  c,
in  n 
)

Create a mesh ellipsoid.

Type MeshEllipsoid for a demo


Form

[v, f] = MeshEllipsoid( a, b, c, n )


Inputs

a           (1,1) x width
b           (1,1) y width
c           (1,1) z width
n           (1,1) Number o grid lines

Outputs

v           (:,3) Vertices
f           (:,3) Faces

◆ MeshSOR()

function MeshSOR ( in  fZOfR,
in  nTheta,
in  nR,
in  rMax 
)

Create a polygonal mesh from a surface of revolution.

The origin is always [0;0;0] and the surface is symmetric about z.


Form

[s, n, a] = MeshSOR( fZOfR, nTheta, nR, rMax )


Inputs

fZOfR      (1,:)       String giving the function. For example 'r.^2' or 'cos(r)'
nTheta     (1,1)       Number of divisions in theta
nR         (1,1)       Number of divisions in r
rMax                   Maximum radius

Outputs

s          (3,:)       Position vectors to the geometric center of each polygon
n          (3,:)       Surface normals of each polygon
a          (1,:)       Area of each polygon

◆ MeshToPatch()

function MeshToPatch ( in  x,
in  y,
in  z,
in  vIn,
in  fIn 
)

Convert a mesh to a patch.

If the arguments v and f are input it will add the new mesh to the existing patch. The mesh will be converted into triangles.


Form

[v, f] = MeshToPatch( x, y, z )


Inputs

x            (:,:) X positions of mesh
y            (:,:) Y positions of mesh
z            (:,:) Z positions of mesh
vIn          (n,3) Vertices
fIn          (m,3) Faces

Outputs

v            (n,3) Vertices
f            (m,3) Faces

◆ MessageQueue()

function MessageQueue ( in  action,
in  modifier,
in  msg,
in  ignoredArg 
)

Creates a message queue GUI.

Once opened, it stays open.

It accumulates messages from any function that sends messages to the queue.


Add this to your code whenever you want a to alert the user to an error.


MessageQueue('add', myFunction ,'The error','error');


Add this to your code whenever you want a to send the user a message.


MessageQueue('add', myFunction ,'The message');


You can turn on a sound notification. Use MessageQueue( 'sound on' ).

Form

MessageQueue( action, modifier, msg, err )


Inputs

action          (1,:)   Action to be taken 
modifier        (1,:)   Action modifier
msg             (1,:)   Message
err             (1,:)   If anything entered an error

Outputs

none

◆ MJD2JD()

function MJD2JD ( in  mJD)

Converts Modified Julian Date to Julian date.

Typing MJD2JD returns the current Julian date.


Form

jD = MJD2JD( mJD )


Inputs

mJD     (1,:)  Modified Julian date (days)

Outputs

jD      (1,:) Julian date (days)

Reference: The Astronomical Almanac for the Year 1993, U.S. Government Printing Office,1993, p. B4.


◆ MLog()

function MLog ( in  action,
in  text,
in  index 
)

Message log.

Keeps an ordered, scrollable set of messages.

Type MLog('demo') for an example.


Form

MLog('init')        % Initialize a new blank MLog window
MLog('init',text)   % Initialize a new blank MLog window with text
MLog('name',name)   % Use the supplied name in the figure heading
MLog('add',text)    % Append text as new element at end of the set
MLog('add',text,k)  % Append text to end of the kth element of the set
MLog('add',text,0)  % Append text to end of the last element of the set
MLog('show',k)      % Show the kth element of the set
MLog('reset')       % Delete stored text array and reset display
t = MLog('get',k)   % Return text of kth element


Inputs

action    ''    Can be: {init, name, add, reset, get}
text      ''    Text to store in MLog window
index     (1,1) Optional. Index of text cell array.

Outputs

t         ''    Text of kth element if called as t = MLog('get',k)

References get().

◆ ModalReductionPlugIn()

function ModalReductionPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a ModalReduction plug in for the ControlDesignGUI.

Typing ModalReductionPlugIn is the same as

ModalReductionPlugIn('initialize')

Form

x = ModalReductionPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ ModalTransform()

function ModalTransform ( in  g)

Transform the system a,b,c,d into modal form.

Creates a balanced realization of the system then uses the eigenvectors to transform into modal coordinates. The retained modes are specified by k.

Type ModalTransform for a demo.


Form

g = ModalTransform( g )


Inputs

g   (:)    State space system

Outputs

g   (:)    Modal form

◆ ModelPlugIn()

function ModelPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create an Model GUI plug in.


Form

x = ModelPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ MSR()

function MSR ( in  g,
in  q 
)

Mean squared response of a system.

It will use the e matrix for 
the input matrix. If that matrix is empty it will use the b matrix.

Form

[x, y] = MSR( g, q )


Inputs

g                 State space system
q                 Spectral density of the white noise process
for 's' or mean squared value for 'z' or 'delta'

Outputs

x           (:)   State response
y           (:)   Measurement response

Reference: Bryson, A.E. Jr., "Control of Spacecraft and Aircraft", Princeton University Press, Princeton, NJ, pp.346-348.


◆ ND2SS()

function ND2SS ( in  num,
in  den 
)

Creates state-space model from numerator and denominator polynomials.

Creates state-space model given a denominator polynomial and
a set of numerator polynomials. The state-space model will be
of the form
.
x = ax + bu
y = cx + du


where each row of C corresponds to a row of num. The output is in
terms of phase variables, also known as the control canonical form.

Form

[a, b, c, d] = ND2SS( num, den )


Inputs

num                 Numerator polynomial(s) one output per row
den                 Denominator polynomial

Outputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix

References: Schultz, D. G., J. L. Melsa, State Functions and Linear Control Systems, McGraw-Hill, New York, 1967, p. 40.


◆ NewFig()

function NewFig ( in  x,
in  varargin 
)

Creates a new figure.

Sets the default axes font size to 12. Applies the global fontSizeIncrease in addition to the 12 pt, if defined. Tags the figure with 'PlotPSS' for use with DemoPSS.


Form

h = NewFig( x, varargin )


Inputs

x          (:)    Name for the figuref
varargin   {}     Parameter pairs to pass to figure()

Outputs

h                 Handle

◆ NLFilter()

function NLFilter ( in  f,
in  h,
in  x,
in  t,
in  k,
in  u,
in  y,
in  dT 
)

Implements a nonlinear fixed gain filter.

Implements a nonlinear fixed gain filter of the form


dx/dt = f(x,u,t) + k*(y - h(x,u,t))


f and h are strings giving the names of functions.


f is of the form f( x, t, u, k, y, h )
h is of the form h( x, u, t )


A 4th order Runge-Kutta is used to propagate the equations of motion.

Form

x = NLFilter( f, h, x, t, k, u, y, dT )


Inputs

f                   Right hand side of the differential equations
h                   Measurement equations
x                   State vector
t                   Time
k                   Gain matrix
u                   Known inputs
y                   Actual measurements
dT                  Time step

Outputs

x                   State vector

◆ Normal()

function Normal ( in  v)

Compute a normal from a set of vertices using the Newell method.


Form

n = Normal( v )


Inputs

v             (3,:)   Polygon vertices

Outputs

n             (3,1)   Normal

References: Hill, F. S. Jr., Computer Graphics, MacMillan, 1990, p. 258.


◆ NormalizePlugIn()

function NormalizePlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create the Normalize GUI plug in used by DetectionFilterBuilder.


Form

x = NormalizePlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ Notch()

function Notch ( in  Kdb,
in  wc,
in  dw,
in  fType,
in  tSamp,
in  sType 
)

Creates a second order transfer function.

Creates a second order transfer function to produce a large + or - gain at frequency wc.

s^2/wc^2 + 2 zzs/wc + 1
K(s) = ------------------------
s^2/wc^2 + 2 zps/wc + 1


For a bandpass with infinite gain at wc enter inf for Kdb. For a
notch with zero gain at wc enter NaN. Any argument for fType
will make the filter nonminimum phase.


Implement this as
x[k] = ax[k-1] + bu[k]
u[k] = cx[k] + du[k]

Form

[a, b, c, d] = Notch( Kdb, wc, dw, fType, tSamp, sType )


Inputs

Kdb                  Peak gain (db)
wc                   Notch frequency (rad/sec)
dw                   Half notch width (rad/sec)
fType                'nmp' means nonminimum phase notch, 'mp'
is minimum phase
tSamp                Sampling frequency
sType                State equation type ('Delta' or 'Z')

Outputs

a                    Plant matrix
b                    Input matrix
c                    Measurement matrix
d                    Feedthrough matrix

References: Wie, B., K. Byun, "New Generalized Structural Filtering Concept for Active Vibration Control Synthesis," J. Guidance and Control, Vol. 12, No. 2, March-April 1989, pp. 147-154.


◆ NPlot()

function NPlot ( in  yLabels,
in  y,
in  x,
in  xAxisLabel,
in  yAxisLabel,
in  plotTitle,
in  figTitle 
)

NPlot generates a plot on which the ylabels are character strings.

The y data is assumed to be integers with each integer corresponding to a label given in yLabels. Will generate a new figure if figTitle is entered.

Any input, except yLabels and y may be [].


Form

NPlot( yLabels, y, x, xAxisLabel, yAxisLabel, plotTitle, figTitle )


Inputs

yLabels                  Labels for the y-axis corresponding to integral
values of y.
y                        y-data
x                        x-data
xAxisLabel               The x-axis label
yAxisLabel               The y-axis label
plotTitle                The plot title
figTitle                 The figure title

Outputs

none

◆ NQuant()

function NQuant ( in  lSB,
in  rType 
)

Computes the variance for various types of roundoff.


Form

[v, m] = NQuant( lSB, rType )


Inputs

lSB                Least significant bit
rType              'round','truncate' Default is 'round' 

Outputs

v                  Variance ( sigma^2 ) 
m                  Mean           

◆ Num2Str1Line()

function Num2Str1Line ( in  n,
in  d 
)

Converts a matrix to a one line string.


Form

s = Num2Str1Line( n, d )


Inputs

n        (:,:)  Number
d        (1,1)  Number of decimal places

Outputs

s        (:)    String

◆ NumericalTransferFunction()

function NumericalTransferFunction ( in  f,
in  dT 
)

Computes a numerical transfer function from the impulse response.

This function uses  an fft but effectively it is integrating
exp(-st)*f(t) dt from zero to infinity. 
If the system is not damped, the results will be poor. For fastest results the 
number of samples should be a power of two.


For a demo type:


NumericalTransferFunction

Form

[l, w] = NumericalTransferFunction( f, dT )


Inputs

f              (1,n)  Impulse response
dT             (1,1)  Time step

Outputs

l              (3,n)  Complex output
w              (1,n)  Frequencies

◆ Nyquist()

function Nyquist ( in  varargin)

Generate a Nyquist plot from a statespace object or gain/phase data.

Type Nyquist for a demo.

Form

[x,y] = Nyquist( g )
[x,y] = Nyquist( g, w )
[x,y] = Nyquist( g, w, iU, iY )
[x,y] = Nyquist( gain, phase )


Inputs

g              (.)     Statespace object (see "statespace")
w              (.)     Frequency vector [rad/s]
iU             (1)     Input index
iY             (1)     Output index
  • -or-
gain          (1,:)    Magnitude from frequency response (see "FResp")
phase         (1,:)    Phase from frequency response [deg]

Outputs

x             (1,:)    x-axis data, gain*cos(phase)
y             (1,:)    y-axis data, gain*sin(phase)

◆ ODETimeDisplay()

function ODETimeDisplay ( in  time,
in  ignoredArg,
in  action,
in  varargin 
)

Displays an estimate of time to go, compatible with ode113.

Pass this function as an outputfcn for a MATLAB ODE. Opens a window displaying the percent complete and an estimate of the time to go. Updates at 0.5 sec intervals. The time to go will not be exact, as the ode is calculating variable time steps, but will become more accurate as the sim progresses.

You can only have one ODETimeDisplay operating at once.


Form

status = ODETimeDisplay( tspan, y0, 'init' )
status = ODETimeDisplay( t, y, '' )
status = ODETimeDisplay( [], [], 'done' )


Inputs

time          (n)      Time
y             (n,1)    Data (currently unused)
action        (1,:)    'init', '', or 'done'

Outputs

None

◆ OGram()

function OGram ( in  a,
in  c 
)

Compute the observability gramian for a continuous time system.


Form

Form

[p, err] = OGram( a, c )



Inputs

a                   State matrix
c                   Output matrix

Outputs

p                   Observability gramian
err                 Norm of the error

◆ OpenFile()

function OpenFile ( in  path,
in  file,
in  suffix,
in  heading,
in  permission 
)

Open a file using a GUI if it is not specified.


Form

[fId, file, path] = OpenFile( path, file, suffix, heading, permission )


Inputs

path       (1,:) Path to file
file       (1,:) File name
suffix     (1,:) Suffix (*.suffix) for the file
heading    (1,:) Heading at top of dialog box
permission (1,:) Permission. Default is r+

Outputs

fID        (1,1) File ID (-1 is failure)
file       (1,:) File name
path       (1,:) Path to file

◆ OpenFrame()

function OpenFrame ( in  x,
in  y,
in  h,
in  t 
)

Generate an open frame.

The panel fits into the frame and the frame is fastened to struts to form a satellite frame. The following runs around the periphery. The inner dimensions are x by y. The thickness (in z) is h. The frame is t by t.

With no outputs this generates a picture. Type OpenFrame for a demo.


Form

[v, f, vol] = OpenFrame( x, y, h, t )


Inputs

x          (1,1) Width of the panel  (x)
y          (1,1) Length of the panel (y)
h          (1,1) Panel thickness
t          (1,1) Frame thickness

Outputs

v          (:,3)  Vertices
f          (:,3)  Faces
vol        (1,1)  Volume of material

◆ OscillatorRHS()

function OscillatorRHS ( in  x,
in  ignoredArg,
in  u,
in  mass,
in  omega 
)

Right hand side for a spring.


Form

xDot = OscillatorRHS( x, t, u, mass )


Inputs

x         (2,1)  [position;velocity]
t         (1,1)  Time
u         (1,1)  Control
mass      (1,1)  Mass
omega     (1,1)  Natural frequency

Outputs

xDot      (2,1)  d[position;velocity]/dt

◆ P3Axis()

function P3Axis ( in  qECIToBody,
in  d 
)

A 3-axis proportional controller.

The control acceleration is equal to the angle error times the gain. Use max_angle to limit the maximum requested angular change per step. The control target is a desired quaternion. The axis and angle are used only to create a prior target on initialization.


Forms:

d = P3Axis; [torque, d] = P3Axis( qECIToBody, d )



Input

qECIToBody (4,1)  ECI to body quaternion
d          (.)    Data structure
.gain            (1,1) Control gain
.q_desired_state (4,1) Target quaternion
.          .q_target_last   (4,1) Last target
.axis            (3,1) Axis of rotation
.angle           (1,1) Angular increment around axis
.max_angle       (1,1) Maximum angle per step (rad)
.inertia         (3,3) Inertia

Output

torque     (3,1) Control torque
d          (.)   Data structure

◆ ParabolicReflector()

function ParabolicReflector ( in  d,
in  f,
in  m,
in  p 
)

Generate a parabolic reflector.

The reflector normal is along +z and the origin is at z = 0. a, n and r include both front and back.

ParabolicReflector will draw the reflector if no outputs are requested.

Type ParabolicReflector for a demo.


Form

[v, f, a, n, h, theta0] = ParabolicReflector( d, f, m, p )


Inputs

d           (1,1)  Diameter (m)
f           (1,1)  Focal length (m)
m           (1,1)  Number of azimuth divisions (optional)
p           (1,1)  Number of elevation divisions  (optional)

Outputs

v           (:,3) Vertices
f           (:,3) Faces
a           (1,:) Areas (m^2)
n           (3,:) Normals
r           (3,:) Vectors to the center of each triangle (m)
h           (1,1) Vertical height of the reflector (m)
theta0      (1,1) Angle from the antenna base to the edge (rad)

Reference: The Parabolic Reflector Antenna (Satellite Dish) http://www.antenna-theory.com/antennas/reflectors/dish.php


◆ Parallel()

function Parallel ( in  a1,
in  b1,
in  c1,
in  d1,
in  a2,
in  b2,
in  c2,
in  d2 
)

Parallel connects two state space models.

Both systems feed off of the same
input and the outputs are the sum of the individual systems outputs.


The resulting system is


[a1  0] [b1] [c1 c2] d1+d2
[ 0 a2] [b2]

Form

[a, b, c, d] = Parallel( a1, b1, c1, d1, a2, b2, c2, d2 )



Inputs

a1                  Plant matrix
b1                  Input matrix
c1                  Measurement matrix
d1                  Input feedthrough matrix
a2                  Plant matrix
b2                  Input matrix
c2                  Measurement matrix
d2                  Input feedthrough matrix

Outputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix

References: Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, p. 373.


◆ PartialDisk()

function PartialDisk ( in  r,
in  t,
in  n,
in  angle 
)

Generate vertices and faces for a full or partial disk.

The axis of rotation is z. Type PartialDisk for a demo showing a full disk and a quarter disk.


Form

[v, f] = PartialDisk( r, t, n, angle )


Inputs

r     (1,1) Radius
t     (1,1) Thickness
n     (1,1) Number of divisions, optional, default 20
angle   (1,2) [start stop], default is 0 to 2*pi

Outputs

v       (:,3) Vertices
f       (:,3) Faces

◆ PathDirectories()

function PathDirectories ( )

Generate a cell array list of all directories in the Matlab path.


Form

d = PathDirectories;


Inputs

none

Outputs

d             {:,1}     Cell array list of all directories in the path

◆ PDDesign()

function PDDesign ( in  zeta,
in  wN,
in  wD,
in  inr,
in  tSamp,
in  sType 
)

Design a PD controller.

Design a PD controller of the form


x = x + ax + bu
y = cx + du


If no outputs are requested then Bode plots for the controller will
be drawn.

Form

[a, b, c, d] = PDDesign( zeta, wN, wD, inr, tSamp, sType )



Inputs

zeta                Damping ratio
wN                  Undamped natural frequency
wD                  Derivative term cutoff
inr                 Axis inertia
tSamp               Sampling period*
sType               State equation type ('Delta' or 'Z')*
* optional - default is a continuous controller

Outputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix

◆ PGains()

function PGains ( in  g,
in  k,
in  w 
)

Compute the principal gains for a system.

Compute the principal gains for a system of the form

  • --— O --— K - G --— O -—
- |                   |
|                   |
-------------------

Form

PGains( g, k, w )


Inputs

g                   Plant model of type statespace
k                   Controller structure of type statespace
w                   Frequency vector

Outputs

None

References: Maciejowski, J.M. (1989). Multivariable Feedback Design. Addison-Wesley, Reading, MA, 76-91.


◆ PhasePlane()

function PhasePlane ( in  v,
in  x,
in  k,
in  db,
in  rl 
)

Implements a phase plane controller.

The optimality condition is


J = T + k*integral[0,T]( |u| dt ) 


where u is the control and T is the final time.


The solution consists of two switching curves. When k is inf you
get the time-optimal solution with one switching curve. If k > 0
you will get two switching curves. The former is known as a
"bang-bang" controller and the latter a "bang-zero-bang" controller.


The deadband separates the switching curves at the origin by db.
The rate limit sets u = 0 if the state is within the control.


Type PhasePlane for a demo.

Form

u = PhasePlane( v, x, k, db, rl )


Inputs

v        (1,1)     Rate
x        (1,1)     Position
k        (1,1)     Weight on time
db       (1,1)     Deadband
rl       (1,1)     Rate limit

Outputs

u        (1,1)     Control [-1;0;1]

Reference: Athans, M. and P. L. Falb. (1966.) Optimal Control Lincoln Laboratory Publication.


◆ PID()

function PID ( in  kF,
in  kP,
in  kR,
in  kI,
in  omegaR,
in  tSamp,
in  sType 
)

Design a PID controller.

Design a PID controller of the form


y =  cx + du
x =  ax + bu


Type PID for a demo.

Form

[g, b, c, d] = PID( kF, kP, kR, kI, omegaR, tSamp, sType )


Inputs

kF                  Forward gain
kP                  Proportional gain
kR                  Rate gain
kI                  Integral
omegaR              Rate cutoff
tSamp               Sampling period (sec)
sType               State equation type ('Delta' or 'Z')

Outputs

g                   Statespace data structure or
[a, b, c, d]        Statespace

◆ PIDesign()

function PIDesign ( in  zeta,
in  wN,
in  inr,
in  tSamp,
in  sType 
)

Design a PI controller.

Design a PI controller of the form


y =  cx + du
x =  ax + bu


using pole placement. Inputs are the damping ratio and undamped natural
frequency of the desired closed loop poles.


If no outputs are requested then Bode plots for the controller will
be drawn.


To ensure that the gain at ƒ is less than 1 make certain that


2*zeta*wN*inr < 1

Form

[a, b, c, d, wC, k] = PIDesign( zeta, wN, inr, tSamp, sType )


Inputs

zeta                Damping ratio
wN                  Undamped natural frequency
inr                 Axis inertia
tSamp               Sampling period
sType               State equation type ('Delta' or 'Z')

Outputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix
wC                  0 dB Crossover
k                   Gain at infinity

◆ PIDMIMO()

function PIDMIMO ( in  inr,
in  zeta,
in  omega,
in  tauInt,
in  omegaR,
in  tSamp,
in  sType 
)

Produces a state space n degree of freedom PID controller.

The PID controller will be of the form:


x(k+1) = a x(k) + b u(k)
y(k)   = c x(k) + d u(k)


By designing in the frequency domain and converting to discrete
time using a zero-order hold. The inputs are the desired damping
ratio and undamped natural frequency of the complex mode of the
closed-loop system and the time constant of the integrator.


This system does not compensate for the phase lag of the zero order
hold and is only applicable to systems where the bandwidth is
much lower than the half-sampling frequency. The continuous time
equivalent for each axis is


Kr s         u
y = Kp u +  ---- u + Ki ---
s + wR        s


The function converts the result to discrete time if tSamp is entered.


If only one output is requested it will return a data structure with
the matrices.

Form

[a, b, c, d, k] = PIDMIMO( inr, zeta, omega, tauInt, omegaR, tSamp, sType )


Inputs

inr           (n,n)    Inertia matrix
zeta          (n,1)    Vector of damping ratios
omega         (n,1)    Vector of undamped natural frequencies
tauInt        (n,1)    Vector of integrator time constants
omegaR        (n,1)    Vector of derivative term roll-off frequencies
tSamp                  Sampling period
sType                  State equation type ('Delta' or 'Z' (default))

Outputs

a             (2n,2n)  Plant matrix
b             (2n, n)  Input matrix
c             ( n,2n)  Output matrix
d             ( n, n)  Feedthrough matrix
k                      Gains
.kP Proportional
.kR Rate
.kI Integral

◆ PIDProper()

function PIDProper ( in  KP,
in  KI,
in  KD,
in  wR,
in  w 
)

Compute proper and non-proper transfer functions for a PID.

Compute proper and non-proper transfer functions for a set of PID gains
Call with no inputs to use default data for a demo.
Call with no outputs to produce a plot.


The transfer function from u to y is of the form:


KD s         u
y = KP u +  ---- u + KI ---
s + wR        s



Notice that with smaller wR, the proper transfer function matches
the original PID (non-proper) transfer function over a higher frequency
range.

Form

data = PIDProper( KP, KI, KD, gamma );


Inputs

KP           (1,1)  Proportional gain
KI           (1,1)  Integral gain
KD           (1,1)  Derivative gain
wR           (1,1)  Derivative roll-off term
w            (1,:)  Frequency vector. Optional, default: logspace(-3,2) 

Outputs

data          (.)   Data structure with fields:
- num       Numerator of proper TF
- den       Denominator of non-proper TF
- numNP     Numerator of proper TF
- denNP     Denominator of non-proper TF
- a         A matrix of proper statespace
- b         B matrix of proper statespace
- c         C matrix of proper statespace
- d         D matrix of proper statespace
- mag       Magnitude response of proper TF
- phase     Magnitude response of proper TF
- magNP     Magnitude response of proper TF
- phaseNP   Magnitude response of proper TF

◆ PIDWithLag()

function PIDWithLag ( in  d)

Creates a PID controller with lag compensation.

Creates a PID controller when there is a lag that you wish to approximately compensate. You enter the ideal integrator time constant, the damping ratio and undamped natural frequency of the complex pole pair. You then select a range of frequencies about you which to compensate for the lag.

Type PIDWithLag for a demo.

Form

y = PIDWithLag( d )


Inputs

d         (1,1)   Data structure
.a    Integrator time constant
.zeta Damping ratio
.wN   Undamped natural frequency
.tau  lag
.w    Range of frequencies to minimize lag effect
.k    Forward gain (e.g 1/mass or 1/inertia)

Outputs

y         (:)     .kI   Integral gain
.kP   Proportional gain
.kD   Derivative gain
.mI   Ideal Integral gain
.mP   Ideal Proportional gain
.mD   Ideal Derivative gain

◆ PILeaky()

function PILeaky ( in  k0,
in  kInf,
in  w0Db,
in  tSamp,
in  sType 
)

Design a leaky PI controller.

Design a PI controller of the form

y =  cx + du
x =  ax + bu


The transfer function is


K ( 1 +    1     ) 
--------
tau(s+a)


The inputs are gain at zero, gain at infinity and 0 dB crossover frequency.
If the gain at zero frequency is not infinity you get a "leaky" integrator.
Leaky integrators can give you sufficient gain a DC for your application
with giving you the stability problems of regular integrators.


With one output, the routine will give you the conventional statespace
form [a, b, c, d]. With one output you will get an object of the statespace
class.


If the gain at infinity is greater than 1, w0Db is the corner frequency.


Type PILeaky for a demo.

Form

[g, b, c, d] = PILeaky( k0, kInf, w0Db, tSamp, sType )


Inputs

k0                  Gain at zero (may be inf) (dB)
k                   Gain at infinity (forward gain) (dB)
w0Db                0 db crossover (rad/sec)
tSamp               Sampling period (sec)
sType               State equation type ('Delta' or 'Z')

Outputs

g                   Statespace data structure or
[g, b, c, d]        Statespace

◆ PlateTwoSided()

function PlateTwoSided ( in  x,
in  y,
in  z 
)

Generate a plate in the xy plane.

Only 4 corners allowed. For correct lighting points must be entered counterclockwise:

4 3 +Y ---------— ^ | | | | | | ---------— --—> +X 1 2

Type PlateTwoSided for a demo.


Form

[v, f] = PlateTwoSided( x, y, z )


Inputs

x           (1,4) x points
y           (1,4) y points
z           (1,1) z

Outputs

v           (4,3) Vertices
f           (4,3) Faces

◆ PlaybackControls()

function PlaybackControls ( in  valMin,
in  valMax,
in  val0,
in  callback,
in  dx,
in  name,
in  position 
)

Create a GUI with playback controls.

Type PlaybackControls for a demo.


Form

PlaybackControls( valMin, valMax, val0, callback, dx, name, position )


Inputs

valMin      (1,1)   Minimum value for slider bar
valMax      (1,1)   Maximum value for slider bar
val0        (1,1)   Initial value of slider
callback            Callback function, 1 var. Example: @(x) disp(sin(x))
dx          (1,1)   Incremental change in x
name        (1,:)   String name for figure (optional)
position    (1,4)   Position in pixels of the figure

Outputs

None

References set().

◆ Plot2D()

function Plot2D ( in  x,
in  y,
in  xL,
in  yL,
in  figTitle,
in  plotType,
in  iY,
in  iX,
in  nCols,
in  pThresh,
in  figBackColor,
in  leg 
)

Easily build a versatile 2D plot page consisting of any number of plots.

Data is indexed into a subplot grid and labels are applied automatically. The data series must be in rows. Any of the inputs, except y, may be omitted or [].

The elements of iY indicate what rows of the y matrix should be plotted on each subplot. If iY is not entered the number of y-axis labels will determine the number of plots on the page. The number of rows of x must equal the number of x labels. If you enter only one row of x it will be used for all plots without the need to enter iX. Otherwise, the elements of iX indicate which rows of the x matrix should be used for each subplot.

For example, to plot a position in a (3,n) matrix:

Plot2D( t, r, 'Time', {'X','Y','Z'}, 'Position Vector' )

or even just

Plot2D( t, r )

To plot this position overlaid with a target,

Plot2D(t,[r;rT],'Time',{'X','Y','Z'},'Position Vector',[],{'[1 4]','[2 5]','[3 6]'})

This function has a built-in demo with 4 subplots showing indexing. Type Plot2D for the demo.


Form

[h, hA] = Plot2D( x, y, xL, yL, figTitle, plotType, iY, iX, nCols, pThresh, figBackColor, leg )


Inputs

x          (m,:)       x values
y          (n,:)       y values
xL       (m,:) or {m}  x-axis label(s)
yL       (n,:) or {n}  y-axis label(s)
figTitle    (:)        Figure title
plotType (n,4) or {n}  Type of axes 'xlog', 'ylog', 'log', 'lin'. 'lin' is the default.
iY       (n,:) or {n}  Index. Indexes Y data to plots. Each row or cell gives the indexes
of the data that go on that plot. This is a string,
either '[1 2 3 4]', '1:3', or an array.
iX         (n,1)       Index. Indexes X data to plots. Each row gives the indexes
of the x data that goes with that plot.
nCol       (1,1)       Number of columns.
pThresh    (1,1)       Minimum plot resolution. Set to 2.220446049250313e-10 for PowerPC
Prevents a MATLAB warning that appears in V5.x.
figBackColor (1)       Flag for fig background color (0 - grey, 1 - white)
leg         {}         Add legends for each plot {{'a', 'b', 'c'},{'x','y'}}

Outputs

h          (1,1)       Figure handle
hA         (:)         Data structure of handles to line objects
.h

◆ Plot3D()

function Plot3D ( in  r,
in  xL,
in  yL,
in  zL,
in  figTitle,
in  rPlanet,
in  figBackColor 
)

Create a 3-dimensional plot.


Form

[h, hA] = Plot3D( r, xL, yL, zL, figTitle, rPlanet, figBackColor  )


Inputs

r          (3,:)    x, y, z values
xL         (n,:)    x-axis label
yL         (n,:)    y-axis label
zL         (n,:)    z-axis label
figTitle            Figure title
rPlanet    (1,1)    Radius of planet sphere
figBackColor (1)    Flag for fig background color (0 - grey, 1 - white)

Outputs

h          (1,1)    Figure handle
hA         (:)      Data structure of handles to line objects
.h

◆ Plot3Vector()

function Plot3Vector ( in  time,
in  vector,
in  title 
)

Plot a 3 vector as x, y, z subplots as well as a combined plot.

Creates 4 subplots. This function has a built-in demo; type Plot3Vector for a demo.


Form

h = Plot3Vector( time, vector, title )


Inputs

time    (1,:)     Time vector, in seconds
vector  (3,:)     Vector data
title    (:)      Title string for plot

Outputs

h       (1,1)     Figure handle

◆ PlotAngleRange()

function PlotAngleRange ( in  varargin)

Plot one or more angular ranges on a unit circle.

Type PlotAngleRange for a demo.


Form

PlotAngleRange( r1, r2, r3, ... )


Inputs

r1        (1,2)   First angular range (rad)
r2        (1,2)   Next angular range (rad)
...

Outputs

None

◆ PlotArrays()

function PlotArrays ( in  action,
in  d,
in  varName,
in  varargin 
)

Manage a set of arrays for plotting simulation data.

Initialize the arrays, store plot points, then obtain arrays. The data is stored internally as multi-dimensional arrays, i.e.

data(m,n,p,...,i,j,k)

For a simple simulation, numberPts is just the size of the simulation loop, for example 100. If you are generating three runs of the same simulation you can pass in [3 100] instead.

The log actions do not run checks for speed. If you attempt to log a variable that you have not added you will get an error.


Forms: d = PlotArrays( 'init', numberPts ) d = PlotArrays( 'add', d, varName, x0 ) d = PlotArrays( 'log', d, varName, index, value ) d = PlotArrays( 'logmulti', d, {varNames}, index, {values} ) x = PlotArrays( 'get', d, varName )



Inputs:


action (:) String with the action name d (1,1) Structure from previous calls
varName (:) String with the variable name numberPts (1,k) The dimensions of the simulation x0 (m,n,p,...) An example of the variable index {1,k} Indices of the data point in a cell array value (m,n,p,...) Value to be stored


Outputs:


d (.) Data structure


◆ PlotColor()

function PlotColor ( in  k)

Generate [r, g, b] for an index k = 1 to 100.


Form

c = PlotColor( k )


Inputs

k          (1,1) Index in range 1 to 100

Outputs

c          (1,3) Color

See also StateDisplay.


◆ PlotDoubleYAxis()

function PlotDoubleYAxis ( in  x,
in  yL,
in  yR,
in  xLabel,
in  yLabelL,
in  yLabelR,
in  title,
in  name,
in  tL,
in  tR 
)

Generates a plot with two y axes.

yL and yR must be 1 by n arrays. x must be 1 by n. If yL is more than one line and the yR has the same number of lines it will match the line colors.

Type PlotDoubleYAxis for a demo.


Form

[hR, hL] = PlotDoubleYAxis( x, yL, yR, xLabel, yLabelL, yLabelR, title, name, tL, tR )


Inputs

x         (1,:) x data
yL        (1,:) Left y axis data
yR        (1,:) Right y axis data
xLabel    (1,:) x label
yLabelL   (1,:) Left y label
yLabelR   (1,:) Right y label
title     (1,:) Figure title
name      (1,:) Figure name
tL        (1,:) Type of right plot 'lin', 'ylog'
tR        (1,:) Type of right plot 'lin', 'ylog'

Outputs

hR        (1,1) Handle to right plot
hL        (1,1) Handle to left plot

◆ PlotF()

function PlotF ( in  action,
in  y,
in  t,
in  g 
)

Create any number of plot pages in one call.

Utilizes Plot2D.

The function is called as:

g = PlotF( 'initialize', [], [], g );
g = PlotF( 'add points', y, t, g );
PlotF( 'plot', g )

All data is stored in g so this function may be called multiple times.


Form

g = PlotF( action, y, t, g )


Inputs

action      (1,:)    Action string
y           (:,1)    Vector to plot
t           (1,1)    Time             (sec)
g           (:)      Data structure
.xLabel
.yLabel {:}   Cell array with y labels
.n      (1,1) Number of plot points
.page   {}    Cell array with indices to plots on each page
.title  {}    Title for each page
ax          (1,1)    Handle to an axes

Outputs

g           (:)      Data structure

◆ PlotPlugIn()

function PlotPlugIn ( in  action,
in  modifier,
in  hFig,
in  position 
)

Plot a variable number of points.

The function is called as:

PlotPlugIn( 'initialize', g, hFig );
PlotPlugIn( 'add points', tag, struct('y',y,'t',t) );
PlotPlugIn( 'plot', tag )
PlotPlugIn( 'update labels', tag, g )


All data is stored in g so this function may be called multiple times.

Form

tag = PlotPlugIn( action, modifier, hFig, position )


Inputs

action      (1,:)    Action
modifier    (1,:)    Modifier to the action.
'initialize'
.xLabel {:}   Cell array with x labels
.yLabel {:}   Cell array with y labels
.n      (1,1) Number of plot points
.title  {:}   Title for each plot
'add points'
tag
hFig        (1,1)    'initialize'
Figure handle
'add points'
.x(:,1)
.y(:,1)

Outputs

g           (:)      Data structure

◆ PlotSet()

function PlotSet ( in  x,
in  y,
in  varargin 
)

Create two-dimensional plots from a data set.

Plot y vs x in one figure. If x has the same number of rows as y then each row of y is plotted against the corresponding row of x. If x has one row then all of the y vectors are plotted against those x variables.

Accepts optional arguments that modify the plot parameters.

Type PlotSet for a demo.


Form

h = PlotSet( x, y, varargin )



Inputs

x         (:,:)  Independent variables
y         (:,:)  Dependent variables
varargin   {}    Optional arguments with values
'x label', 'y label', 'plot title', 'plot type'
'figure title', 'plot set', 'legend', 'line width'

Outputs

h         (1,1)  Figure handle

See also Plot2D


◆ PlotV()

function PlotV ( in  x,
in  xLbl,
in  yLbl,
in  zLbl,
in  figTitle 
)

Draws plots of a set of 3*m-by-n vectors in 3D axes.

To plot more than one vector, stack them:

x = [ x1;x2;...]

Does not draw vectors from the origin but rather plots the sequence of the vector tips. See MAPControlSim for an example. Type PlotV for a demo.


Form

PlotV( x, xLbl, yLbl, zLbl, figTitle )


Inputs

x           (3*m,n)   Vectors
xLbl                  X label
yLbl                  Y label
zLbl                  Z label
figTitle              Figure title

Outputs

None

◆ PltStyle()

function PltStyle ( )

Edit this to globally change the plot styles for the plot labels.


Form

[style, font, fSI] = PltStyle()


Inputs

none

Outputs

style     Font style
font      Font
fSI       Font size increase (above default size)

◆ PoissonsRatio()

function PoissonsRatio ( in  material)

Returns Poisson's ratio.

If no arguments are entered it will return a list of materials.

Form

PoissonsRatio
nu = PoissonsRatio( material )


Inputs

material (1,:) Material string.

Outputs

nu       (1,:) Poisson's ratio 

◆ Polygon()

function Polygon ( in  v)

Generate the properties for a polygon given vertices in the form v(3,n).

It assumes that the polygon is planar. It computes an average normal at all vertices.


Form

[area, n, r] = Polygon( v )


Inputs

v          (3,:)       Vertices

Outputs

area       (1,1)       Area of the polygon
n          (3,1)       Normal
r          (3,1)       Geometric center

Reference: Hill, F.S., Jr. Computer Graphics.


◆ PolygonProps()

function PolygonProps ( in  v,
in  f 
)

Polygon properties from vertex and face data.


Form

[a, n, r, b] = PolygonProps( v, f )


Inputs

v        (:,3)    Vertices
f        (:,3)    Faces

Outputs

a        (:,1)    Area
n        (:,3)    Normal
r        (:,3)    Geometric center
b        (:,1)    Equivalent radius

◆ PositionLabel()

function PositionLabel ( in  x)

With an input in meters give a reasonable output scale.


Form

[x, s] = PositionLabel( x )


Inputs

x            (1,:) Position (m)

Outputs

x            (1,:) Position
s            (1,:) Label (m, km, au, light year)

◆ PrincipalAxes()

function PrincipalAxes ( in  inertia,
in  u 
)

Computes the principal axes for an inertia matrix.

Input u is a set of vectors for which the routine computes angles between the axes in the base and axes in the principal frame. The inertia matrix in principal axes is m'*inertia*m


Form

[inertiaP, angle, error, m] = PrincipalAxes( inertia, u )


Inputs

inertia   (3,3)   The inertia matrix
u         (3,n)   Vectors in the base frame

Outputs

inertiaP  (3,3)   The inertia matrix
angle     (1,n)   Angle between u in base and u in principal axes (deg)
error     (3,3)   Error
m         (3,3)   Transformation matrix

◆ PrintEigenvalues()

function PrintEigenvalues ( in  g,
in  f,
in  t 
)

Print eigenvalues to the command window.

Type PrintEigenvalues for a demo.

Form

PrintEigenvalues( g, f, t )


Inputs

g               (:)      State space system or a matrix
f               (1,:)    Format, ie:  '%7.3f'
t               (1,:)    Title

Outputs

f               (:)      Gain matrix

◆ PrintFig()

function PrintFig ( in  invertHardCopy,
in  printType,
in  f,
in  fName,
in  pathName,
in  zBuffer 
)

Prints specified figures to a printer or files.

The figures may be printed to an encapsulated Postscript file, jpeg or png. (For eps will always use -depsc2 -tiff, for jpeg -jpeg90). The default (any number > 3) is pdf, which uses exportgraphics. To send figures to the default printer use 0 for the type parameter.


Form

PrintFig( invertHardCopy, printType, f, fName, pathName, zBuffer )


Inputs

invertHardCopy  If true will invert the color of the printed figure
printType       If == 1 will make eps file (default); 2, png; 3, jpeg. 
Greater than 3 prints to a pdf file. To
send to the default printer use 0.
f               Set of figures to print
fName           File name (no extension)
pathName        Path to the file
zBuffer         Print in zbuffer mode (before R2014b)

Outputs

none                   

◆ PrintTitle()

function PrintTitle ( in  t)

Print a title with — under and above.


Form

PrintTitle( t )


Inputs

t               (1,:)    Title

Outputs

none

◆ ProcessTag()

function ProcessTag ( in  action,
in  tag,
in  k,
in  name 
)

Code used to process tags for sensors and actuators.


Form

[k, tag] = ProcessTag( action, tag, k, name )


Inputs

action  (1,:) Action
tag     {:}   Tag list
k       {:}   Index or tag
name    (1,:) Name of calling function

Outputs

k          {:}  Index
tag     {:}  Tag list

◆ PropStateSpace()

function PropStateSpace ( in  g,
in  x,
in  u 
)

Propagate a state space model.

Uses the state space class.

Form

[x, y] = PropStateSpace( g, x, u )


Inputs

g           (:)   Model of type statespace
x           (:)   State vector
u           (:)   Input

Outputs

x           (:)   State vector
y           (:)   Output vector

◆ PWM()

function PWM ( in  tau,
in  tSamp,
in  n 
)

Create a model of a pulsewidth modulator using Padé approximants.

The pulsewidth is assumed fixed at tau. The function includes the
sampler gain of 1/tSamp;

Form

[a, b, c, d] = PWM( tau, tSamp, n )
[num, den]   = PWM( tau, tSamp, n )


Inputs

tau           (1,1) Nominal pulsewidth
tSamp         (1,1) Sampling period
n             (1,1) Number of terms (optional)

Outputs

a or num            Numerator polynomial or plant matrix
b or den            Denominator polynomial or input matrix
c                   Measurement matrix
d                   Feedthrough matrix

◆ Q2AU()

function Q2AU ( in  q)

Convert a quaternion to an angle and a unit vector.

If q = [1;0;0;0] then u is set to [1;0;0].


Form

[angle, u] = Q2AU( q )


Inputs

q       (4,1)   Quaternion

Outputs

angle   (1,1)   Angle
u       (3,1)   Unit vector

◆ Q2Eul()

function Q2Eul ( in  q,
in  e 
)

Converts a quaternion to 3-2-1 Euler angles.

Uses the input e(1) for e(1) near the singularity.


Form

e = Q2Eul( q, e )


Inputs

q       (4,1)  Quaternion
e       (3,1)  Euler angles

Outputs

e       (3,1)  Euler angles

◆ Q2Mat()

function Q2Mat ( in  q)

Converts a quaternion to a transformation matrix.

Does not check to see that m is orthonormal. This routine requires 45 floating point operations.


Form

m = Q2Mat( q )  


Inputs

q       (4,1)  Equivalent quaternion

Outputs

m       (3,3)  Orthonormal transformation matrix

References: Shepperd, S. W., Quaternion from Rotation Matrix, J. Guidance, Vol. 1, No. 3, May-June, 1978, pp. 223-224.


Since version 1.


◆ QAxisRot()

function QAxisRot ( in  qi,
in  angle,
in  u 
)

Creates a quaternion based on a pure rotation about the any axis.

When the input angle is 0, q = qi.


Form

q = QAxisRot( qi, angle, u )    


Inputs

qi            (4,1)  Initial quaternion from a to b
angle         (1,1)  Angle (rad)
u             (1,1)  Axis of rotation

Outputs

q             (4,1)  Quaternion a to c

◆ QBToIDot()

function QBToIDot ( in  q,
in  w,
in  dT 
)

Computes the quaternion derivative from angular velocity.

Computes the time derivative of a quaternion that transforms from the body frame to the inertial frame given the angular velocity measured in the body frame.


Form

qD                 = QBToIDot( q, w )   
[a, b, c, d, dqdt] = QBToIDot( q, w )
[a, b, c, d, dqdt] = QBToIDot( q, w, dT )


Inputs

q              (4,1)  Quaternion from b to a
w              (3,1)  Rate of b with respect to a measured in b
dT             (1,1)  Time step

Outputs

qD             (4,1)  Derivative of Q


or


a                     Plant matrix
b                     Input matrix
c                     Measurement matrix
d                     Feedthrough matrix
dqdt                  Constant quaternion derivative

◆ QCE()

function QCE ( in  a,
in  c,
in  q,
in  r,
in  b,
in  n 
)

Create an estimator from a state space system.

Create an estimator based on the state equations

x = ax + bw y = cx + v

E(ww') = q
E(vv') = r
E(vw') = n


The estimator will be of the form


xE = a*xE + b*u + k*(y-c*xE)

Form

[k, sInf] = QCE( a, c, q, r, b, n )


Inputs

a                   Plant matrix
c                   Measurement matrix
q                   State noise covariance matrix
r                   Measurement noise covariance matrix
b                   State noise input matrix
n                   State/measurement cost cross-coupling covariance matrix

Outputs

k                   Optimal gain
sInf                Covariance matrix

References: Bryson, A., Y. Ho, Applied Optimal Control, Hemisphere, 1976, 364-373.


◆ QCR()

function QCR ( in  a,
in  b,
in  q,
in  r,
in  n 
)

Creates a linear quadratic regulator from a state space system.

Create a regulator of the form u = -Kx minimizing the cost functional J = †{(1/2)[u'ru + x'qx] + u'nx + x'nu}dt.

Given the constraint:
.
x = ax + bu

Form

[k, sinf] = QCR( a, b, q, r, n )


Inputs

a                   Plant matrix                              (N,N)
b                   Input matrix                              (N,M)
q                   State cost matrix                         (N,N)
r                   Input cost matrix                         (M,M)
n                   State/input cost cross-coupling matrix    (N,M)

Outputs

k                   Optimal gain
sinf                Solution to the matrix Ricatti equation

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, pp. 435-438.


◆ QError()

function QError ( in  qRef,
in  qMeas,
in  ignoredArg 
)

Small angle errors between two quaternions.

This routine gives the correct sign when both vectors transform from frame a to frame b and frame b is the body frame. If the convention is reversed you must reverse the sign. To force the positive first element convention enter any 3rd argment.


Form

angle = QError( qRef, qMeas, pos )


Inputs

qRef            (4,1)  Reference quaternion
qMeas           (4,1)  Measured quaternion
pos             (1,1)  If entered make the first element positive
always

Outputs

angle           (3,1)  Vector of small angular errors (rad)

◆ QForm()

function QForm ( in  q,
in  ua 
)

Transforms a vector in the direction of the quaternion.

If the number of columns of q is 1 it will transform all of the vectors by that q. If it is greater than 1 it will transform each column of ua by the corresponding column of q. If the number of columns of q is > 1 and the number of columns of ua is 1 it will create one column of ub for every column of q. This routine takes 30 floating point operations.


Form

ub = QForm( q, ua )


Inputs

q              (4,n or 1)  Quaternion from a to b
ua             (3,n or 1)  Vector in a

Outputs

ub             (3,n)       Vector in b

See also QTForm.


◆ QFromDQ()

function QFromDQ ( in  q,
in  dQ24 
)

Computes a quaternion from a base quaternion and delta quaternion.

The delta quaterion is only elements 2 through 4.

Type QFromDQ for a demo.


Form

q = QFromDQ( q, dQ24 )


Inputs

q       (4,1)   Base quaternion
dQ24    (4,1)   Quaternion elements 2 through 4

Outputs

q       (4,1)  Updated quaternion

◆ QMult()

function QMult ( in  Q2,
in  Q1 
)

Multiply two quaternions.

Q2 transforms from A to B and Q1 transforms from B to C so Q3 transforms from A to C. If only one argument is input it produces the 4x4 matrix equivalent: q3 = Q2*q1;


Form

Q3 = QMult( Q2 ,Q1 )    


Inputs

Q2              (4,1)  Quaternion from a to b
Q1              (4,1)  Quaternion from b to c

Outputs

Q3              (4,1)  Quaternion from a to c or 4x4 version of q

◆ QPose()

function QPose ( in  q)

Transpose of a quaternion.


Form

qp = QPose( q )


Inputs

q                   (4,:)  quaternion from a to b

Outputs

qp                  (4,:)  quaternion from b to a

◆ QRand()

function QRand ( in  n)

Generates random quaternions.

The first element is always positive.


Form

q = QRand(n)


Inputs

n   (1,1)   Number of quaternions

Outputs

q   (4,n)   Random quaternions.    

◆ QTForm()

function QTForm ( in  q,
in  ua 
)

Transforms a vector opposite the direction of the quaternion.

If the number of columns of q is 1 it will transform all of the vectors by that q. If it is greater than 1 it will transform each column of ua by the corresponding column of q. If the number of columns of q is > 1 and the number of columns of ua is 1 it will create one column of ub for every column of q.


Form

ub = QTForm( q, ua )


Inputs

q              (4,n or 1)  quaternion from a to b
ua             (3,n or 1)  vector in frame b

Outputs

ub             (3,n)       vector in frame a


See also QForm.

◆ Quant()

function Quant ( in  x,
in  lsb,
in  rType 
)

Quantizes a matrix using user defined rounding.


Form

[xQ, xCounts] = Quant( x, lsb, rType )


Inputs

x                      Vector to be quantized
lsb                    Least significant bit
rType                  Type of rounding ['round','floor','ceil','fix']

Outputs

xQ                     Quantized x
xCounts                X in numbers of lsbs

◆ QuickPlot()

function QuickPlot ( in  file)

Plots output data from external simulations.

Call with no inputs to select a file manually.


Form

[v, yLbls, time, name] = QuickPlot( file )


Inputs

file    (1,:)   File name

Outputs

v       {:}     Each cell is a plot {'state' 'output' 'input'}
yLbls   {:}     Each cell is the y-axis name
time    (1,:)   The time data
name    {:}     The plot names

◆ QUnit()

function QUnit ( in  q)

Unitizes a quaternion.

Quaternions are assumed to be the columns of q.


Form

qu = QUnit( q )


Inputs

q               (4,:)  Quaternions

Outputs

qu              (4,:)  Unitized quaternions

◆ QZero()

function QZero ( )

Outputs the zero quaternion, [1;0;0;0].


Form

q = QZero


Inputs

None

Outputs

q              (4,1)  Zero quaternion

◆ Rad2DMS()

function Rad2DMS ( in  a)

Convert radians to degrees, minutes and seconds.


Form

[d, m, s] = Rad2DMS( a )


Inputs

a              (3,:)  Angle in radians

Outputs

d              (1,:)  degrees
m              (1,:)  minutes
s              (1,:)  seconds


or


d              (3,:)  [degrees;minutes;seconds]

References: The 1993 Astronomical Almanac, p. C24.


◆ Rad2HMS()

function Rad2HMS ( in  a)

Convert radians to hours, minutes and seconds.


Form

[h, m, s] = Rad2HMS( a )


Inputs

a              (1,:)  Angle in radians

Outputs

h              (1,:)  hours
m              (1,:)  minutes
s              (1,:)  seconds


or


h              (3,:)  [hours;minutes;seconds]

References: The 1993 Astronomical Almanac, p. C24.


◆ RaDec2U()

function RaDec2U ( in  rA,
in  dec 
)

Converts right ascension and declination to unit vectors.


Form

u = RaDec2U( rA, dec )


Inputs

rA    (1,n) Right ascension (rad)
dec   (1,n) Declination (rad)

Outputs

u     (3,n) Unit vectors

◆ RadioButtons()

function RadioButtons ( in  action,
in  modifier,
in  hFig,
in  position,
in  rows,
in  format,
in  cB 
)

Create radio buttons.

Units are pixels. format is a cell array of the orm

{'property1', value, 'property2', value, ... }

To initialize type:

RadioButtons( 'initialize', {'a', 'b', 'c'}, hFig )


Form

tag = RadioButtons( 'initialize', s, hFig, position, rows, format, cB )
x = RadioButtons( 'value',  tag )
x = RadioButtons( 'string', tag )
x = RadioButtons( 'show', tag )
x = RadioButtons( 'hide', tag )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifier    (1,:)  Modifier to the action
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
s           {}     Cell array of strings
position    (1,4)  [left bottom width height]
rows        (1,1)  Number of rows
format      {:}    Cell array of properties
cB          (1,:)  Callback

Outputs

x           (1,1)  Output     

◆ Rates2EulDot()

function Rates2EulDot ( in  e,
in  w,
in  n 
)

Converts angular velocity into 3-2-1 Euler angle rates.

If only one

input is given, the output is the transformation matrix.

Form

wEul = Rates2EulDot( e, w, n )


Inputs

e       (3)    Euler angles
w       (3)    Angular rates
n   (1)    Orbit rate (for rotating frames only, optional)

Outputs

wEul        (3)    Euler angle rates

Reference: Hughes, Spacecraft Attitude Dynamics (1986), Table 2.2 p. 27


◆ ReadCSVTable()

function ReadCSVTable ( in  filename)

Read in tabular data in .csv file and convert it to a structure array.

Textual column headers are required to define structure field names. Type ReadCSVTable for a file selection GUI.


Form

d = ReadCSVTable( filename )


Inputs

filename     (:)  Name of .csv file with tabular data

Outputs

d            (.)  Data structure array. Each row is a struct element.
The structure field names are the column headers.

◆ RealTimePlot()

function RealTimePlot ( in  action,
in  y,
in  t,
in  g 
)

Plot real time.

All data is stored in g so this function may be called multiple times.


Form

g = RealTimePlot( action, y, t, g )


Inputs

action      (1,:)    Action
y           (:,1)    Vector to add to plot
t           (1,1)    Time (sec)
g           (:)      Data structure
.tLabel
.tLim   (1,2) [start stop]
.yLim   (:,2) [min max] if equal RealTimePlot will use [-1 1]
.yLabel {:}   Cell array with y labels
.page   {}    Cell array with indices to plots on each page
.title  {}    Title for each page                       

Outputs

g           (:)      Data structure

◆ ReduceModal()

function ReduceModal ( in  g,
in  k 
)

Retain modes k of the system a,b,c,d.

Creates a balanced realization of the system then uses the eigenvectors to transform into modal coordinates. The retained modes are specified by k.

Type ReduceModal for a demo.


Form

g = ReduceModal( g, k )


Inputs

g   (:)    State space system
k   (1,:)  Modes to retain

Outputs

g   (:)    Reduced state space system

◆ ReduceOrder()

function ReduceOrder ( in  g,
in  k 
)

Retain states k of the system a,b,c,d.

Type ReduceOrder for a demo.


Form

g = ReduceOrder( g, k )


Inputs

g                   (:)    State space system

Outputs

g                   (:)    State space system

References: Meserole, J. S., "Detection Filters for Fault-Tolerant Controlo f Turbofan Engines." MIT 1981.


◆ ReduceOrderPlugIn()

function ReduceOrderPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a model order reduction GUI plug in.

ReduceOrderPlugIn('initialize')


Form

x = ReduceOrderPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ ReliabilityMOfN()

function ReliabilityMOfN ( in  m,
in  n,
in  mTBF,
in  t 
)

Determine the reliability of a system.

n parallel devices of which m should survive. The reliability is exp(-t/MTBF).


Form

p = Reliability(m,n,mTBF,t)


Inputs

n     (1,1)  Number that must survive
m       (1,1)  Number of devices
mTBF    (1,1)  Mean time between failure for each unit (s)
t     (1,:)  Time vector (s), optional (default 0 to 4*mTBF)

Outputs

p     (1,:)  Reliability of the system (probability of failure)

Reference: Daniele Veneziano. 1.151 Probability and Statistics in

Engineering. Spring 2005. Massachusetts Institute of Technology: MIT OpenCourseWare, https://ocw.mit.edu. Application note: "RELIABILITY OF SYSTEMS WITH VARIOUS ELEMENT CONFIGURATIONS"


◆ ReliabilityParallel()

function ReliabilityParallel ( in  n,
in  mTBF,
in  t 
)

Determine the reliability of a parallel system.

Compute the probability of failure for n parallel devices. The reliability is exp(-t/MTBF).


Form

r = ReliabilityParallel(n,mTBF,t)


Inputs

n       (1,:)  Number of devices for each MTBF
mTBF    (1,:)  Mean time between failure for each unit (s)
t     (1,:)  Time vector (s), default 0 to 6*max(mTBF)

Outputs

p     (1,:)   Probability of failure

Reference: Daniele Veneziano. 1.151 Probability and Statistics in

Engineering. Spring 2005. Massachusetts Institute of Technology: MIT OpenCourseWare, https://ocw.mit.edu. Application note: "RELIABILITY OF SYSTEMS WITH VARIOUS ELEMENT CONFIGURATIONS"


◆ ReliabilitySeries()

function ReliabilitySeries ( in  n,
in  mTBF,
in  t 
)

Determine the reliability of a series system.

Compute the probability of failure for n series devices. The reliability is exp(-t/MTBF).


Form

p = ReliabilitySeries(n,mTBF,t)


Inputs

n       (1,p)  Number of devices
mTBF    (1,p)  Mean time between failure for each unit (s)
t     (1,:)  Time vector (s)

Outputs

p     (1,:)  Probability of failure

Reference: Daniele Veneziano. 1.151 Probability and Statistics in

Engineering. Spring 2005. Massachusetts Institute of Technology: MIT OpenCourseWare, https://ocw.mit.edu. Application note: "RELIABILITY OF SYSTEMS WITH VARIOUS ELEMENT CONFIGURATIONS"


◆ RemoveContentsFile()

function RemoveContentsFile ( in  x)

Removes the 'Contents.m' file from a cell array of file names.


Form

y = RemoveContentsFile( x )


Inputs

x           {}       Cell array of strings

Outputs

y           {}       Cell array of strings

◆ Rename()

function Rename ( in  x,
in  f 
)

Renames a figure title.

If f is not entered it renames the current figure.


Form

Rename( x, f )


Inputs

x                    Name
f                    Figure id

Outputs

none

◆ RequiredFields()

function RequiredFields ( in  g,
in  r 
)

Returns 1 if the data structure g has the required fields in r.


Form

x = RequiredFields( g, r )


Inputs

g            (:    Data structure
r            {}    Cell array with required fields

Outputs

x            (:)   Returns a 1 if g(k) does not have all required fields

◆ RFromCPAndGamma()

function RFromCPAndGamma ( in  cP,
in  gamma 
)

Computes R from cP and gamma.


Form

m = RFromCPAndGamma( cP, gamma )


Inputs

cP         (1,n)   Specific heat
gamma      (1,n)   Gamma

Outputs

r          (1,n)   Gas constant

◆ RHSDoubleIntegrator()

function RHSDoubleIntegrator ( in  x,
in  ignoredArg,
in  u,
in  mass 
)

Right hand side for a double integrator.

This is the same as DoubleIntegratorRHS.


Form

xDot = RHSDoubleIntegrator( x, t, u, mass )


Inputs

x         (2,1)  [position;velocity]
t         (1,1)  Time
u         (1,1)  Control
mass      (1,1)  Mass

----—~

Outputs

xDot      (2,1)  d[position;velocity]/dt

◆ RHSNLSpring()

function RHSNLSpring ( in  x,
in  ignoredArg,
in  d 
)

Nonlinear estimator spring model.

Has a linear and cubic spring plus a damper.


Form

d = RHSNLSpring;
xDot = RHSNLSpring( x, t, d )


Inputs

x         (2,1)  State [position;velocity]
t         (1,1)  Time (not used)
fData     (1,1)  Data structure
.kL (1,1) Linear spring coefficient
.kC (1,1) Cubic spring coefficient
.c  (1,1) Damping coefficient
.f  (1,1) Force
.x0 (1,1) Nominal x

Outputs

xDot      (2,1)  State derivative

◆ RHSOscillator()

function RHSOscillator ( in  x,
in  ignoredArg,
in  u,
in  mass,
in  omega 
)

Right hand side for a spring.


Form

xDot = OscillatorRHS( x, t, u, mass )


Inputs

x         (2,1)  [position;velocity]
t         (1,1)  Time
u         (1,1)  Control
mass      (1,1)  Mass
omega     (1,1)  Natural frequency

Outputs

xDot      (2,1)  d[position;velocity]/dt

◆ RHSPartialNLSpring()

function RHSPartialNLSpring ( in  ignoredArg,
in  ignoredArg,
in  d 
)

Nonlinear estimator spring model.

Has a linear and cubic spring plus a damper.


Form

d = RHSPartialNLSpring;  % data structure
a = RHSPartialNLSpring( x, t, d )


Inputs

x         (2,1)  State [position;velocity] (not used)
t         (1,1)  Time (not used)
d          (.)   Data structure
.kL (1,1) Linear spring coefficient
.kC (1,1) Cubic spring coefficient
.c  (1,1) Damping coefficient
.f  (1,1) Force
.x0 (1,1) Nominal x
.m  (1,1) Mass

Outputs

a         (2,2)  State transition matrix

◆ RHSSpring()

function RHSSpring ( in  x,
in  ignoredArg,
in  d 
)

Computes the right hand side for a linear spring.


Form

xDot = RHSSpring( x, ~, d )


Inputs

x   (2,1) State [x;v]
t   (1,1) Time (s) (unused)
d   (.)   Data structure
.zeta   (1,1) Damping ratio
.w      (1,1) Undamped natural frequency  (rad/s)
.m    (1,1) Mass (kg)

Outputs

xDot       (2,1) d[x;v]/dt

◆ RHSX()

function RHSX ( in  x,
in  ignoredArg,
in  d 
)

Right hand side for a one dimensional vertical motion simulation.

Adds Gaussian random variations to the thrust.


Form

d    = RHSX;
xDot = RHSX( x, t, d )


Inputs

x             (2,1)  [x;v]
t             (1,1)  Time (not used)
d             (1,1)   Data structure
.m        (1,1) Mass
.g        (1,1) Acceleration of gravity
.tNoise   (1,1) Standard deviation of thrust
.t0       (1,1) Average thrust

Outputs

xDot           (2,1)   State derivative

◆ Riccati()

function Riccati ( in  g)

Solves the matrix Riccati equation.

Solves the matrix Riccati equation in the form


g = [a   r ]
[q  -a']

Form

[sinf, rr] = Riccati( g )


Inputs

g                  Input matrix 

Outputs

sinf               Steady-state solution
rr                 Repeated roots 1 = repeated roots

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, pp. 435-438.


◆ Ring()

function Ring ( in  rO,
in  rI,
in  l,
in  w,
in  n 
)

Generate a ring with specified inner and outer wall, and length.

The origin is at the bottom. Type Ring for a demo.


Form

[v, f] = Ring( rO, rI, l, w, n )


Inputs

rO  (1,1) Outer radius
rI  (1,1) Inner radius
l   (1,1) Length of middle section
w   (1,1) Front and back wedge length
n   (1,1) Number of divisions

Outputs

v   (:,3) Vertices
f   (:,3) Faces

◆ RootLocus()

function RootLocus ( in  g,
in  k 
)

Generate the root locus for s SISO system.

Requires a statespace system as an input.


Type RootLocus for a demo.

Form

RootLocus( g, k )


Inputs

g           (1,1) State space system
k           (1,:) Gains

Outputs

None

◆ RootSort()

function RootSort ( in  r)

Sort columns of roots for Root Locus.

Each column is a root list generated by eig. It tries to match the
roots in column k with those in column k-1.

Form

s = RootSort( r )


Inputs

r              (n,m)  Roots

Outputs

s              (n,m)  Sorted roots

◆ RotMat()

function RotMat ( in  angle,
in  axis 
)

Generates a rotation matrix that transforms in the opposite direction.

of the rotation. Angle may be one to three. Axis gives the order of
transformation. For example:


axis = [1;2;3]


then b = b(3)*b(2)*b(1)


and v            = b*v
unrotated        rotated


If angle has more than one column, then b will be


[b1, b2, b3, ..., bn]


and each row of bK will give the column indices of the 
corresponding transformation matrix. For example, to get the
3rd transformation matrix type


b(:,bK(3,:))

Form

[b, bK] = RotMat( angle, axis )


Inputs

angle       (:,n)            Angle (rad)
axis        (:,n)            Axis of rotation

Outputs

b           (3,n)            Transformation matrix
bK          (3,n)            Indexes to n

◆ RouthArray()

function RouthArray ( in  p)

Computes the Routhian array for a polynomial.

Type RouthArray for a demo.

Form

r = RouthArray( p )


Inputs

p         (1,n)  Polynomial

Outputs

r         (n,:)  Routh array       

Reference: http://classes.engr.arizona.edu/ame558/public_html /topic1/page2.html


◆ RPhiTheta2Cart()

function RPhiTheta2Cart ( in  r)

Computes the transformation matrix from an r, phi, theta frame.

to a standard cartesian frame. In an RPT frame, r is the radial
direction, phi is 'east', and theta is in the direction of
co-elevation. When theta is zero the r vector is in the xy-plane.

Form

cRPT2Cart = RPhiTheta2Cart(r)



Inputs

position    (3,1)  Position in cartesian coordinates. 

Outputs

cRPT2Cart   (3,3)  The transformation matrix

◆ RTSS()

function RTSS ( in  mP,
in  pP,
in  m,
in  p,
in  a 
)

Rauch-Tung-Striebel smoothing.

This assumes a discrete model of the form:

x[k] = a[k-1]x[k-1] + b[k-1]u[k-1] y[k] = h[k]x[k]

You pass all of the filter matrices that were already generated by a Kalman Filter.

Type RTSS for a demo of a double integrator system.


Form

[mS, pS] = RTSS( mP, pP, m, p, a )


Inputs

mP            (n,:)    Mean vector from KF prediction step
pP            (n,n,:)  Covariance matrices from KF prediction step
m             (n,:)    Mean vector from KF
p             (n,n,:)  Covariance matrices from KF
a             (n,n,:)  State transition matrices

Outputs

mS            (n,1)    Smoothed mean vector
pS            (n,n)    Smoothed covariance matrix

◆ S2Damp()

function S2Damp ( in  s)

Eigenvalues to damping and natural frequency.

◆ S2Z()

function S2Z ( in  a,
in  b,
in  c,
in  d,
in  dT,
in  sType 
)

Transform an s-plane transfer function into the z-plane.

If only 3 inputs are given it assumes the input is in transfer
function form. Otherwise it assumes state equation from

Form

[numz, denz, k] = S2Z( nums, dens, dT, sType )
[f, g, h, j]    = S2Z( a, b, c, d, dT, sType )


Inputs

a                    State transition matrix or Numerator polynominal
b                    Input matrix or dens
c                    Output matrix or T
d                    Feedthrough matrix
T                    Sampling period
sType                'bilinear', 'zoh', 'forward', 'backward'

Outputs

f                    Discrete state matrix or numerator polynomial
g                    Discrete input matrix or denominator polynomial
h                    Output matrix or gain
j                    Feedthrough matrix

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, p. 137-147.


◆ Sa2Q()

function Sa2Q ( in  av)

Converts an angle vector into a quaternion.

Angles are defined as positive rotating frame a into b and the
resulting quaternion transforms from frame a to b.


Form

q = Sa2Q( av )


Inputs

av             (3,1)  Angle vector from a to b

Outputs

q               (4,1)  Quaternion from a to b

◆ SaveMovie()

function SaveMovie ( in  m,
in  fileName 
)

Save a MATLAB movie.

.avi will be appended to the file name.

Changing the figure window size while recording will cause this function to fail.

Type SaveMovie for a demo creating and saving a movie of a SCARA robot.


Form

SaveMovie( m, fileName )


Inputs

m           (1,1)  Movie file
fileName    (1,:)  File name 

Outputs

None

◆ SaveStructure()

function SaveStructure ( in  gXXXX,
in  fileName 
)

Save a structure in a file.

You will be able to read it in by typing

g = load('fileName');

Form

SaveStructure( gXXXX, fileName )


Inputs

gXXXX    (:)   Structure
fileName (1,:) .mat file name

Outputs

None

◆ SectorPatch()

function SectorPatch ( in  r0,
in  u1,
in  u2,
in  scale 
)

Compute faces and vertices for a sector patch.

The sector origin is at the point r0. One edge of the sector is pointed along the unit vector u1. The other edge is along the unit vector u2. The sector patch is computed as a set of triangles with length "scale" that bridge the two vectors.

Type SectorPatch for a demo.


Form

[f,v] = SectorPatch( r0, u1, u2, scale )


Inputs

r0      (3,1)   Origin of sector
u1      (3,1)   Unit vector for one edge
u2      (3,1)   Unit vector for other edge
scale   (1,1)   Scale defines length (radius) of sector

Outputs

f       (:,3)   Faces
v       (:,3)   Vertices

◆ SecToString()

function SecToString ( in  s)

Convert seconds to days hours/min/seconds and produces a string.


Form

dateString = SecToString( s )


Inputs

s     (1,1)  Seconds

Outputs

dS    (1,:)  Date string

◆ Selection()

function Selection ( in  list,
in  msg,
in  name 
)

Selection GUI.


Form

[k,item] = Selection( list );


Inputs

list             {:}  Cell array of strings to choose from
msg              (:)  Message to display in GUI (string)
name             {:}  Name in title bar of GUI (string)

Outputs

k                (1)  Index of chosen item
item             (:)  Chosen item

Copyright (c) 2004 Princeton Satellite Systems, Inc. All rights reserved.


◆ SelectS()

function SelectS ( in  a,
in  b,
in  c,
in  d,
in  kS,
in  kO,
in  kI 
)

Extract selected states from a state space model.


Form

[a, b, c, d] = SelectS( a, b, c, d, kS, kO, kI )


Inputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix
kS                  Selected states
kO                  Selected outputs
kI                  Selected inputs

Outputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix

◆ Series()

function Series ( in  a1,
in  b1,
in  c1,
in  d1,
in  a2,
in  b2,
in  c2,
in  d2 
)

Series connects two state space models.

Series connects two state space models so that y2 is the output
and u1 is the input.


u1 ----> P1 -----> P2 -----> y2


Since version 1.

Form

[a, b, c, d] = Series( a1, b1, c1, d1, a2, b2, c2, d2 )



Inputs

a1                  Plant matrix
b1                  Input matrix
c1                  Measurement matrix
d1                  Input feedthrough matrix
a2                  Plant matrix
b2                  Input matrix
c2                  Measurement matrix
d2                  Input feedthrough matrix

Outputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix

References: Maciejowski, J. M., Multivariable Feedback Design, Addison-Wesley, Reading, MA, 1989, pp. 372-373.


◆ SetCopy()

function SetCopy ( in  k,
in  w,
in  h 
)

Set the dimensions of the figure when copied or printed.


Form

SetCopy( k, w, h )


Inputs

k                      Figure handle(s)
w                      Width (in)
h                      Height (in)

Outputs

None                  

◆ SetFont()

function SetFont ( in  name,
in  size,
in  angle,
in  style 
)

Sets default fonts.

Sets the following properties:

  • DefaultAxesFontName
  • DefaultTextFontName
  • DefaultAxesFontSize
  • DefaultTextFontSize
  • DefaultAxesFontAngle
  • DefaultTextFontAngle
  • DefaultAxesFontWeight
  • DefaultTextFontWeight

Form

SetFont( name, size, angle, style )


Inputs

name                     Font name
size                     Font size
angle                    Font angle ('italic') 'normal' is the default.
style                    Font style or weight ('bold')

Outputs

none

◆ SetUIElement()

function SetUIElement ( in  h,
in  varargin 
)

Set certain properties of UIElements.

property

'visible' 'on', 'off' 'enable' 'on', 'off' 'position' [x y width height]

If the style is not for a UIElement, it will automatically pass the arguments to uicontrol.


Form

SetUIElement( h, varargin )


Inputs

h          (:)   Handle
varargin   {:}   Property pairs

Outputs

none

◆ SFunc()

function SFunc ( in  t,
in  x,
in  u,
in  flag 
)

An example s-function that interfaces mfiles to Simulink.

It implements the function

dx/dt = f( t, x, u );

This is a simple simulation of an orbit. To customize this function you need to:

  • Edit the top of the main function to initialize your model
  • Edit ModelInitializeSizes to set up the model state, input and output

    dimensions

  • Edit ModelDerivatives to have your right hand side
  • Edit ModelOutputs to output your outputs

Form

[sys, x0, str, ts] = SFunc( t, x, u, flag )


Inputs

t                  Time
x                  State
u                  Inputs
flag               Simulink control flag

Outputs

ssys, x0, str, ts  Required Simulink outputs

◆ ShapedStrut()

function ShapedStrut ( in  x1,
in  x2,
in  c 
)

Generate strut going from x1 to x2.

Set the origin at the center of the crossection otherwise the ends may not look correct. Type ShapedStrut for a demo.


Form

[v, f, volume] = ShapedStrut( x1, x2, c )


Inputs

x1         (3,1) Location of top
x2         (3,1) Location of bottom
c          (1,1) Crossection data
.x (1,m) x locations
.y (1,m) y locations

Outputs

v          (:,3)  Vertices
f          (:,3)  Faces
volume     (1,1)  Volume of the strut

See also Polygon and Extrude.


◆ ShapeFlt()

function ShapeFlt ( in  wN,
in  width,
in  depth,
in  wL,
in  tSamp,
in  sType 
)

Generates a shaping filter with notches and first order roll off.

If no outputs are specified it will generate a Bode plot of the 
continuous system. The widths of the notches should be proportional 
to the center frequency.


For example wN = 0.01 and width = 0.001 will look the same as
wN = 0.001 and width = 0.0001.

Form

[a, b, c, d] = ShapeFlt(  wN, width, depth, wL, tSamp, sType )


Inputs

wN            (m)     Center of notch         (rad/sec)
width         (m)     Width of notch          (rad/sec)
depth         (m)     Filter depth            (dB)
wL            (1,1)   Low pass cutoff         (rad/sec)
tSamp         (1,1)   Sampling period         (sec)
sType         (1,1)   State equation type     ('Delta' or 'Z')

Outputs

a             (n,n)   State matrix
b             (n,1)   Input matrix
c             (1,n)   Output matrix
d             (1,1)   Feedthrough matrix

◆ ShowThreeImages()

function ShowThreeImages ( in  x,
in  y,
in  z,
in  title 
)

Display three images.

If x, y or z are 2 dimensional ColorMapGrayScale is used for the color mapping.

Type ShowThreeImages for a demo


Form

[h,hX,hY,hZ,s] = ShowThreeImages( x, y, z, title )


Inputs

x          (n,m,3 or 1)   uint8 (0 - 255) or double (0 - 1) RGB image 1
y          (n,m,3 or 1)   uint8 (0 - 255) or double (0 - 1) RGB image 2
z          (n,m,3 or 1)   uint8 (0 - 255) or double (0 - 1) RGB image 3

Outputs

h          (1,1)          Figure handle
hX         (1,1)          X figure axes handle
hY         (1,1)          Y figure axes handle
hZ         (1,1)          X figure axes handle
s          (1,1)          Image scaling

See also image, ColorMapGrayScale


◆ SigmaPointsChol()

function SigmaPointsChol ( in  d,
in  p,
in  varargin 
)

UKF sigma points using chol.

See UKFWeight for definitions of alpha and kappa


Form

d = SigmaPointsChol( d, p )


Inputs

d             (.)   Data structure
.cSqrt  (1,1) sqrt(alpha^2*(length(x) + kappa))
.dX     (1,1) Number of states
.x      (:,1) Current state


p             (n,n) Covariance matrix

Outputs

d             (.)   Data structure
.xA    (:,:) Sigma points

Reference: Simo Sarkka, "Bayesian Estimation of Time-Varying Systems: Discrete-Time Systems, Version 1.3 (March 2, 2012).


◆ SimpAtm()

function SimpAtm ( in  altitude,
in  units 
)

Simplified atmosphere model.

Agrees with the standard atmosphere model but is faster. Type SimpAtm for a demo.


Form

d = SimpAtm( altitude, units )


Inputs

altitude   (:)     Altitude (m or ft)
units      (1,:)   'si' or 'eng' i.e. m & kg or lb & ft

Outputs

d          (.)     Standard atmosphere
.temperature
.pressure
.density
.speedOfSound
.kinematicViscosity

◆ SimulatePlugIn()

function SimulatePlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a Simulate GUI plug in used by DetectionFilterBuilder.


Form

x = SimulatePlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ SISOListPlugIn()

function SISOListPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a list of SISO elements for use by control design tools.

Allows the user to input parameters.

Typing SISOListPlugIn is the same as SISOListPlugIn('initalize')


Form

x = SISOListPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ SISOPlugIn()

function SISOPlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create an SISO GUI plug in.

h.block   .g       (1,1) Complete block model of class statespace
.gBase   (1,1) Base model (cannot be separated into SISO elements)
.sISO    (:)   .g          (:)   Controller statespace representation
.type       {:}   Controller type
.m          {:}   Controller parameters
.connection (1,1) 'base input', 'base output', 'parallel'
.inputs     {:}   Inputs
.outputs    {:}   Outputs 

Typing SISOPlugIn is the same as SISOPlugIn('initialize')


Form

x = SISOPlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if initialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ SizeAB()

function SizeAB ( in  a,
in  b 
)

Checks the dimensions of the set a, b for consistency.


Form

notOK = SizeAB( a, b )


Inputs

a                   Plant matrix
b                   Input matrix

Outputs

notOK               Not correct if equal to 0

◆ SizeABCD()

function SizeABCD ( in  a,
in  b,
in  c,
in  d 
)

Checks the dimensions of the set a,b,c,d for consistency.

d need not be input.

Form

notok = SizeABCD( a, b, c, d )


Inputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix (optional)

Outputs

notok               Not correct if equal to 0

◆ SizeAC()

function SizeAC ( in  a,
in  c 
)

Checks the dimensions of the set a, c for consistency.

These are the state transition and state input matrices.

Form

notOK = SizeAC( a, c )


Inputs

a                   Plant matrix
c                   Measurement matrix

Outputs

notOK               Not correct if equal to 0

◆ SliderBar()

function SliderBar ( in  valMin,
in  valMax,
in  val0,
in  callback,
in  name,
in  position,
in  fig 
)

Create a slider in a new figure with continuous calls to callback.

Can optionally put the slider into an existing figure. Type SliderBar for a demo.


Form

SliderBar( valMin, valMax, val0, callback, name, position, fig )


Inputs

valMin      (1,1)   Minimum value for slider bar
valMax      (1,1)   Maximum value for slider bar
val0        (1,1)   Initial value of slider
callback            Callback function, 1 var. Example: @(x) disp(sin(x))
name        (1,:)   String name for figure (optional)
position    (1,4)   Position information. 
* If a new figure is created, this input defines 
the position of the new figure in pixels on the
screen. OR...
* If an existing figure is specified, this input
defines the position of the slider within the
given figure window. 
fig         (1,1)   Figure handle. Optional. Supply this input to put
the slider inside this figure, rather than creating
a new figure.

Outputs

u           (1,1)   Handle to the slider object.

References set().

◆ SortColumnCell()

function SortColumnCell ( in  x)

Sort a nxm cell array by the values in the first column.

Type SortColumnCell for a demo.


Form

s = SortColumnCell( x )


Inputs

x              {m,n}  Cell array

Outputs

s              {m,n}  Cell array

◆ SortFigs()

function SortFigs ( in  h,
in  xo 
)

Sort figure windows by cascading them.


Form

SortFigs( h, xo )


Inputs

h            (1,:)   Array of figure handles. Optional. If not
provided, all current figure handles will be used.
xo            (1)    Horizontal offset for first figure. Optional,
default is 0.

Outputs

h            (1,:)   Array of figure handles.

◆ Sph2Cart()

function Sph2Cart ( in  r,
in  theta,
in  phi 
)

Converts spherical coordinates to cartesian.


Form

[x, y, z] = Sph2Cart( r, theta, phi )


Inputs

r                     (:,:)  Either r or [r;theta;phi]
theta                 (:)    theta (angle in xy-plane)
phi                   (:)    phi 

Outputs

x                     (:,:)  Either x or [x;y;z]
y                     (:)    y
z                     (:)    z

◆ Splash()

function Splash ( )

Draw a splash screen.

Loads the xSplash MAT-file and displays it in a new figure. The figure is closed after 4 seconds.


Form

Splash


Inputs

None

Outputs

None

◆ SRiccati()

function SRiccati ( in  g)

Solves the matrix Riccati equation.

The equation is in the form:


g = [a   -brb' ]
[-q  -a'   ]

Form

sinf = SRiccati( g )


Inputs

g                  Input matrix 

Outputs

sinf               Steady-state solution

References: Laub, A.J. (1979). A Schur Method for Solving Algebraic Riccati Equations. IEEE Transactions on Automatic Control, AC-24(6), 913-921.


◆ SS2ND()

function SS2ND ( in  a,
in  b,
in  c,
in  d,
in  iu 
)

Converts from state space to numerator denominator form.

Creates a transfer function model of a state-space system from
one input channel to all of the output channels using
the relationship


det(sI-A+bc) - (1-d)det(sI-A)
c*inv(sI-A)*b + d = -----------------------------
det(sI-A) 


where c is a row vector and b a column vector.

Form

[num, den] = SS2ND( a, b, c, d, iu )


Inputs

a                   Plant matrix
b                   Input column vector
c                   Output row vector
d                   Feedthrough element
iu                  Input channel

Outputs

num                 Numerator polynomial(s) one output per row
den                 Denominator polynomial

References: Kalaith, T., Linear System, Prentice-Hall, Englewood-Cliffs, NJ, 1980.


◆ SSEmpty()

function SSEmpty ( )

Creates an empty state space system.

a = [], b = [], c = [], d = 1;

Form

[a, b, c, d] = SSEmpty


Inputs

None

Outputs

a                      Plant matrix
b                      Input matrix
c                      Output matrix
d                      Feedthrough matrix

◆ SSFromNonlinear()

function SSFromNonlinear ( in  f,
in  x,
in  t,
in  u,
in  kUse,
in  varargin 
)

Computes state space matrices from a nonlinear function.

This function computes state space matrices from f(x,t,u,varargin).
The RHS must be of the form f(x,t,u,varargin).

Form

[a, b] = SSFromNonlinear( f, x, t, u, k, varargin )


Inputs

f              (1,:)  Dynamical function name
x              (n,1)  Nominal state
t              (1,1)  Time
u              (m,1)  Nominal control
kUse           (1,:)  States to use
varargin              Arguments passed to f

Outputs

a              (n,n)  State matrix
b              (n,m)  Input matrix

◆ Staircase()

function Staircase ( in  t,
in  dT,
in  varargin 
)

Generates steps for any number of inputs.

Since version 10.

For example: t = [0 10 100]; v = [0 20 30]; h = [10 4 33];

[tS,vS,hS] = Staircase(t,0.1,v,h)


Form

[tS, varargout] = Staircase( t, dT, varargin )


Inputs

t              (1,:)  Transition times
dT             (1,1)  Time step
varargin       {:}    Any number of input variables

Outputs

tS             (1,p)  Times for each step
varargout      {:}    Ramps corresponding to varargin's
m              (1,:)  Mass of tank
v              (1,:)  Volume

◆ StateDisplay()

function StateDisplay ( in  action,
in  varargin 
)

Draw a 3D covariance display in real-time.

Type StateDisplay for a demo.


Form

tag = StateDisplay( action, varargin )


Inputs

action     (3,:) Action 'initialize' or 'update'


when 'update'
state      (:,:) New state


when 'initialize'
k          (2,:) Elements of p to display
e          (3,1) Errors
state      (3,:) Initial state
position   (1,4) Position
hFig       (1,1) Figure handle

Outputs

tag        (1,1) Handle to the display

◆ StatePrp()

function StatePrp ( in  a,
in  b,
in  c,
in  d,
in  x,
in  u,
in  sType 
)

Propagates state equations.


Form

[y, x] = StatePrp( a, b, c, d, x, u, sType ) 


Inputs

a                      State transition matrix
b                      Input matrix
c                      Measurement matrix
d                      Feedthrough matrix
x                      State
u                      Input
sType                  If omitted z-transform, else delta.

Outputs

y                      Output
x                      State

◆ StateSpacePlugIn()

function StateSpacePlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create an StateSpace GUI plug in used by DetectionFilterBuilder.


Form

x = StateSpacePlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ StdAtm()

function StdAtm ( in  altitude,
in  AtmData,
in  units 
)

Computes atmospheric density based on the standard atmosphere model.

To get a table of standard atmosphere data type

load -ascii AtmData;

Type StdAtm for demo.


Form

d = StdAtm( altitude, AtmData, units  )


Inputs

altitude   (:)     Altitude (m or ft)
AtmData    (:,6)   Standard atmosphere data.
units      (1,:)   'si', 'mks' or 'eng' i.e. m & kg or lb & ft

Outputs

d          (.)     Standard atmosphere struct
.temperature
.pressure
.density
.speedOfSound
.kinematicViscosity

x is [altitude (m) temperature (deg-K) pressure (N/m^2) density (kg/m^3)

speed of sound (m/s) kinematic viscosity (m^2/s)] or

[altitude (ft) temperature (deg-R) pressure (lbf/ft^2) density (lbf/m^3) speed of sound (ft/s) kinematic viscosity (ft^2/s)]


◆ SteadyS()

function SteadyS ( in  a,
in  b,
in  c,
in  d,
in  y,
in  q,
in  r 
)

Determine the steady state control for a state space system.

.
x = Ax + Bu
y = Cx + Du


given y. If the number of inputs is less than the number of 
outputs it computes a weighted least squares fit to y using
the weighting matrix q. If the number of inputs is greater
than the number of outputs it minimizes the function u'ru. 
If q is not input it uses the identity matrix.

Form

[u, x, yC] = SteadyS( a, b, c, d, y, q, r )


Inputs

a                   Plant matrix
b                   Input matrix
c                   Output matrix
d                   Feedthrough matrix
y                   Desired output
q                   Weighting matrix for y
r                   Weighting matrix for u

Outputs

u                   Steady state control
x                   Steady state state
yC                  Achievable y if number of outputs > number of controls

Reference: Bryson, A.E., Jr. (1994). Control of Spacecraft and Aircraft Princeton University Press, Princeton, NJ.


◆ Step()

function Step ( in  g,
in  iU,
in  dT,
in  nSim,
in  inputType,
in  statesFlag 
)

Generate a step response of a state space system.

If no outputs are given it will plot.

Form

[y,x,t] = Step( g, iU, dT, nSim, inputType, statesFlag )


Inputs

g                      State space system of type statespace
iU           (n)       Input* optional, defaults to all
dT           (1)       Time step*
nSim         (1)       Number of steps*
inputType    (:)       'step', 'impulse', 'white noise'* optional,
defaults to a step response.
statesFlag   (1)       Flag for plotting the states, optional.

Outputs

y           (p,m)      Step response
x           (n,m)      States
t           (1,m)      Time vector

◆ STKAtt()

function STKAtt ( in  fileName,
in  ver,
in  epoch,
in  nPoints,
in  time,
in  attitude,
in  type,
in  seq 
)

Prints attitude data to STK-formatted file.


Form

[err, message] = STKAtt(fileName,ver,epoch,nPoints,time,attitude,type,seq)


Inputs

fileName           Filename for output. Will be overwritten 
if it already exists.
ver                STK version number (string!)
epoch              Beginning date and time: [Y M D H M S]
nPoints            Number of attitude data points
time               Time in seconds for each data point
attitude           Attitude data describing the rotation from
ECI J2000 to body, see input 'type' for 
allowable types
type               'quaternion','Euler','YPR','ECIVector',or
'ECFVector'
seq                Rotation sequence for Euler or yaw-pitch-
roll angles, ex. [1 2 3]

Outputs

err                err ~= 0 means an error occurred
message            Error message

◆ STKOrbit()

function STKOrbit ( in  fileName,
in  ver,
in  epoch,
in  nPoints,
in  time,
in  position,
in  velocity,
in  type 
)

Prints orbit data to STK-formatted file.


Form

[err, message] = STKOrbit( fileName, ver, epoch, nPoints, time,
position, velocity, type )


Inputs

fileName           Filename for output. Will be overwritten 
if it already exists.
ver                STK version number (string!)
epoch              Beginning date and time: [Y M D H M S]
nPoints            Number of orbit data points
time               Time in seconds for each data point
position           Position data in km (if type = ECF
or ECI) or in [degrees,degrees,km]
(if type = LLR)
velocity           Velocity data in km/sec (if type = ECF
or ECI) or [degrees,degrees,km]/sec
(if type = LLR)
type               'ECI','ECF',or 'LLR'

Outputs

err                err ~= 0 means an error occurred
message            Error message

◆ StopGUI()

function StopGUI ( in  name)

GUI for stopping scripts.

Has Pause, Stop, and Plot buttons.

See ShuttleSim for an example.

Typing StopGUI is the same as StopGUI('Stopping GUI')


Form

StopGUI( name )


Inputs

name    (1,:) GUI name      

Outputs

None       

See also: TimeCntrl


◆ StringMatch()

function StringMatch ( in  s,
in  sA,
in  ignoredArg 
)

Finds which elements of sA match s.

Uses strcmp and strcmpi internally. An alternative to strmatch which is no longer recommended by MathWorks.

Type StringMatch for a demo


Form

k = StringMatch(s,sA,~)


Inputs

s     (1,:) String
sA    {:}   Cell array of strings
nC    (1,1) If entered, ignore case

Outputs

k    (1,:)  Elements of sA that match s

◆ StringToToken()

function StringToToken ( in  s)

Finds the first token in a string.


Form

[t, r] = StringToToken( s )


Inputs

s       (:)   String (may be a cell element)

Outputs

t       (1,:) Character string with the token
r       (1,:) Remainder of the string

◆ StringToTokens()

function StringToTokens ( in  s,
in  delimiters,
in  noSpace 
)

Converts a string to a list of tokens.


Form

t = StringToTokens( s, delimiters, noSpace )


Inputs

s          (:)   String (may be a cell element)
delimiters (:)   List of delimiters added to whitespace
noSpace    (1,1) If entered will not use whitespace as a delimiter

Outputs

t          {}    Cell array of tokens

◆ StrMtch()

function StrMtch ( in  s,
in  sM 
)

In a matrix with each row a string finds the first matching string.


Form

k = StrMtch( s, sM )


Inputs

s   (1,:)   String
sM  (:,:)   Strings to test

Outputs

k   (1,:)   Row index for matching string

◆ StructToCell2D()

function StructToCell2D ( in  x)

Convert a structure into a cell array.

Where columns of the array
include both values and fieldnames. For example, the struct


x.a = 1
x.b.c = 2;
x.b.d = 3;


Becomes


a  1
b  c  2
b  d  3


The companion array m is


1 0 1
1 1 0
1 1 0


Where a 1 indicates that the cell is a field name.


This function contains a recursive call. Therefore the depth of the
structure must be less than the number of recursions.
The struct may have one dimensional cells as elements.

Form

[y, m] = StructToCell2D( x )


Inputs

x         (1,1)   Structure

Outputs

y        (:)    Cell Array
m        (:)    Index matrix 1 = field, 0 = data

◆ StructToText()

function StructToText ( in  data,
in  textFileName 
)

Write data structure to a text file or command line display.

The fields will be printed in order with the space-separated data starting on the next line, as in:

mass:
1.0

Matrices are prepended with the size in rows and columns.

az (1,8):
0 0.785398 1.5708 2.35619 3.14159 3.92699 4.71239 5.49779 

Small column vectors will be displayed as a transpose to save vertical space. This function gracefully displays function handles, cell arrays, strings, and matrices. For all other object types, disp is called.

Passing in a 1 for textFileName will print the text to the command line, and this is the default behavior if no file name or fid is entered.


Form

StructToText( data, textFileName )
StructToText( data, fid )


Inputs

data             (.)   Data structure
textFileName     (:)   Name of text file to write to, or fid

Outputs

none

◆ StructureList()

function StructureList ( in  action,
in  modifier,
in  d,
in  name,
in  position,
in  hFig 
)

Creates a list of structures and variables.

d may contain data structures or any type of variable in its cell array. On initialization it returns the handle to the list. Also 'modifier' is a call back string that StructureList should call when an element in the list is selected. When an element in a list is selected an array is created with pointers to the element and to all structures to which it is attached. This can be used to identify the element in a structure.


Form

s = StructureList( action, modifier, d, name, position, hFig )


Inputs

action          (1,:)   Action to be taken 
modifier        (1,:)   Modifier to the action
d               {}      Cell array of data structures
name            {}      Cell array of data structure name
position        (1,4)   Position of the frame
hFig            (1,1)   Handle to the figure

Outputs

hL              (1,:)   Handle to the selected field
tag             (1,:)   StructureList tag

◆ Strut()

function Strut ( in  x1,
in  x2,
in  r1,
in  r2,
in  n 
)

Generate a variable radius strut going from x1 to x2.

If r2 is omitted, r2 = r1. If n is omitted n = 10.

Type Strut for a demo.


Form

[v, f, vol] = Strut( x1, x2, r1, r2, n )


Inputs

x1         (3,1) Location of top
x2         (3,1) Location of bottom
r1         (1,1) Radius at top
r2         (1,1) Radius at bottom, optional
n          (1,1) Number of circumferential divisions (default is 10)

Outputs

v         (:,3)  Vertices
f         (:,3)  Faces
vol       (1,1)  Volume

See also: Frustrum


◆ SVPlot()

function SVPlot ( in  g,
in  w 
)

Computes the maximum and minimum singular values.


Form

[sMin, sMax, w] = SVPlot( g, w )


Inputs

g                   System data structure of type statespace
w                   Frequency vector

Outputs

sMin                Minimum singular values
sMax                Maximum singular values
w                   Frequency vector

◆ Symmetrize()

function Symmetrize ( in  p)

Makes a square matrix symmetric by adding its transpose and dividing.

by two.

Type Symmetrize for a demo

This is often used to fix matrices that are slightly asymmetric due to numerical errors. This is particularly useful with Kalman filters for maintaining a symmetric covariance matrix.


Form

p = Symmetrize( p )


Inputs

p   (n,n) Matrix

Outputs

p   (n,n) Symmetric matrix

◆ SystemTime()

function SystemTime ( in  action,
in  mET,
in  jD 
)

Provides the system time to the software.


Form

[mET, jD] = SystemTime( action, mET, jD )


Inputs

action       (1,:) Action to take
mET          (1,1) Mission elapsed time
jD           (1,1) Julian Date

Outputs

mET          (1,1) Mission elapsed time
jD           (1,1) Julian Date

◆ T2JD()

function T2JD ( in  T)

Converts Julian centuries from J2000.0 to days.


Form

jd = T2JD( T )


Inputs

T      (1,:)  Julian centuries of 86400s dynamical time from j2000.0

Outputs

jd     (1,:)  Julian date (days)

◆ TabBox()

function TabBox ( in  action,
in  modifier,
in  tabs,
in  content,
in  position,
in  hFig,
in  formatInfo,
in  data,
in  callback 
)

Create a tab box from plug-ins.


Form

[x, y, tag] = TabBox( action, modifier, tabs, content, position, hFig, 
formatInfo, data, callback)


modifier is passed to the content functions as their action
units are defined externally. When a contents function is called
action is used as the function name and modifier as the action.


Inputs

action         (1,:)    Action to be taken
modifier       (1,:)    Modifier to the action
tabs           {n}      Cell array with tab labels
content        {n}      Cell array with function names that define
the content
position       (1,4)    [left,bottom,width,height] content region only!
hFig           (1,1)    Figure handle 
formatInfo     (1,1)    Data structure with format information
.FontAngle       (1,:)
.FontName        (1,:)
.FontSize        (1,1)
.FontUnits       (1,1)
.FontWeight      (1,:)
.ForegroundColor (1,3)
data           {}       Initialization data
callback       (1,:)    CreateCallback function when a control in a panel is hit

Outputs

x              {}      Tags for panels
y              {}      Handles to tab buttons
tag            {}      Tag for the frame around the tab box. Userdata of this
frame provides access to all of the parts of the tab box

◆ TAI2TT()

function TAI2TT ( in  tAI)

Converts Terrestrial atomic time to Terrestrial dynamic time.


Form

tDT = TAI2TT( tAI )


Inputs

tAI     (:,:) Terrestrial atomic time

Outputs

tDT     (:,:) errestrial (dynamic) time

◆ TDB2TT()

function TDB2TT ( in  tDB,
in  jD 
)

Converts barycentric dynamical time.

Used as time-scale of ephemerides referred to the barycentre of the solar system to terrestrial dynamic time.


Form

tT = TDB2TT( tDB, jD )


Inputs

tDB      (:,:) Terrestrial dynamic barycenter time
jD       (:,:) Julian date (days)

Outputs

tT       (:,:) Terrestrial (dynamic) time

References: The Astronomical Almanac for the Year 1993, U.S. Government Printing Office,1993, p. B5.


◆ Telemetry()

function Telemetry ( in  action,
in  modifier,
in  u,
in  v 
)

Generates a GUI with a set of telemetry pages.

To initialize:


Telemetry( 'initialize', d, onlineHelpFileName, tagForTelemetryGUI )


The structure array d. d has the form


d.telemetryNames{:}
d.units{:}
d.format{:} C format strings
d.page(:)


where 


page(k).name
page(k).columns
page(k).telemetryPoint(:) A row by row list of points corresponding to
the names


or a mat file name with the above information or if no input
it will ask for a mat file of the correct form. See TelemetryDemo.


To update the pages, type 


Telemetry( 'update', tag, u )


where u is the data corresponding to d.telemetryNames. u has three fields
u.data
u.time
u.timeFormat 'Calendar' 'sec', 'JD'
You must input Julian Date for JD or calendar.
Calendar time format is a string 'mm/dd/yyyy hh:mm:ss'


To increase internal memory allocation search for nTelemetryPoints
and set to a larger number.


To quit type


Telemetry( 'quit', tag );

Form

tag = Telemetry( action, modifier, u, v )


Inputs

action          (1,:)   Action to be taken by the message center
modifier        (:)     Modifier to the message
u               (:)     Help file name
v               (:)     Data structure or name of the telemetry
data file

Outputs

tag             (1,:)   Returns the window tag on initialization

◆ TelemetryOffline()

function TelemetryOffline ( in  action,
in  modifier 
)

This GUI plots telemetry files previously saved by Telemetry.


Form

tag = TelemetryOffline( action, modifier, u )


Inputs

action          (1,:)   Action to be taken by the message center
modifier        (:)     Modifier to the message

Outputs

tag             (1,:)   Returns the window tag on initialization

◆ TelemetryPlot()

function TelemetryPlot ( in  action,
in  modifier,
in  u 
)

Plot real time data in a single window.


Form

tag = TelemetryPlot( action, modifier, u )


Inputs

action      (1,:)    Action
modifier    (:)      On initialization this is the struture
.tLabel
.tLim   (1,2) [start stop]
.yLim   (:,2) [min max] if equal RealTimePlot will use [-1 1]
.yLabel {:}   Cell array with y labels
.t      (1,1) Initial time                       
.y      (1,1) Initial state vector                      
u           (:)      .data   {:}   Data
.t      (1,1) Time

Outputs

tag         (1,1)    Tag to the plot page

◆ TextInBox()

function TextInBox ( in  pos,
in  s,
in  varargin 
)

Draw text in a box.


Form

TextInBox( pos, s, varargin )


Inputs

pos       (1,2) [x, y] Upper left corneere
s         (1,:) string
varargin    {}    Parameter pairs: 'fontsize' 'fontname' 'boxcolor'
'edgecolor' 'boxopacity' 'textcolor' 'edgewidth'

Outputs

None

◆ TextS()

function TextS ( in  x,
in  y,
in  s,
in  k 
)

Prints labels on a graph using text with toolbox style settings.


Form

TextS( x, y, s, k)


Inputs

x                 x location
y                 y location
s          (:)    Text
k                 Passed to text

Outputs

None

See also PltStyle


◆ TimeCntrl()

function TimeCntrl ( in  action)

Perform actions specified by the time display.

This routine is called by a callback routine in TimeGUI.m. You do not normally call it yourself.

Initialize the global as follows:

global simulationAction
simulationAction = ' ';

Use the following code in your simulation loop:

switch simulationAction
case 'pause'
pause
simulationAction = ' ';
case 'stop'
return;
case 'plot'
break;
end

Form

TimeCntrl( action )


Inputs

action    (1,:) Action to take

Outputs

None

◆ TimeDisplay()

function TimeDisplay ( in  action,
in  varargin 
)

Displays an estimate of time to go.

Call TimeDisplay('update') each step; the step counter is incremented automatically. This GUI does NOT provide any simulation controls (pause/stop). Updates at 0.5 sec intervals.

TimeDisplay( 'initialize', nameOfGUI, totalSteps ) TimeDisplay( 'update' ) TimeDisplay( 'close' )

You can only have one TimeDisplay operating at once.


Form

TimeDisplay( action, varargin )


Inputs

action        (1,:)    'initialize' 'update' 'close'
nameOfGUI     (1,:)    Name to display
totalSteps    (1,1)    Total number of steps

Outputs

None

◆ TimeGUI()

function TimeGUI ( in  totalSteps,
in  stepsDone,
in  tToGoMem,
in  rRT,
in  dT,
in  name 
)

A GUI displaying the time remaining and estimated completion time.

Useful for simulations and other slow tasks. Computes the time left to go in the simulation, the predicted finish time and the ratio of simulation time to real time. This routine should be called at regular intervals. It will update the GUI no faster then 5 times a second to prevent the graphics from slowing down the simulation.

Type TimeGUI( 'close' ) to close the GUI.

See also TimeGUIDemo.


Form

[ rRT, tToGoMem, tToGo, tDone ] = TimeGUI( totalSteps, stepsDone,...
tToGoMem, rRT, dT, name )


Inputs

totalSteps             Total number of steps in the simulation
stepsDone              Number of steps completed
tToGoMem               Memory [lastJD, lastStepsDone, number of averages done]
rRT                    Ratio of simulation time to real time
dT                     Simulation time step (sec) 
name                   Name of simulation          

Outputs

rRT                    Ratio of simulation time to real time
tToGoMem               Memory [lastJD, lastStepsDone, number of averages done]
tToGo                  Time left in the simulation
tDone                  Predicted clock time of finish

◆ TimeHistory()

function TimeHistory ( in  t,
in  y,
in  yL,
in  figTitle,
in  yList,
in  leg 
)

Time history plots.

Creates a set of plots, one for each row of yL. t is assumed to be in seconds. It will automatically scale time units. If yList is entered you can have multiple plots per axis. yList must be the same size as yL leg adds legends. It must be in the for {{} {}} where there is one cell array per plot.

Type TimeHistory for a demo.


Form

[hFig,hL] = TimeHistory( t, y, yL, figTitle, yList, leg )


Inputs

t           (1,:)   Time (s)
y           (n,:)   Y values
yL          {m,1}   Y-axis labels
figTitle    (1,:)   Figure title
yList     {m,1} Plots per figure
leg       {m,1} Legend

Outputs

hFig      (1,1) Figure handle
hL        (:,1) Line handles

See also Plot2D, TimeLabl


◆ TimeLabel()

function TimeLabel ( in  t0)

Produce time labels and scaled time vectors.

Generates a time series from a time series in seconds with more reasonable units: minutes, hours, days, or years.


Form

[t, u, s, f] = TimeLabel( t0 )


Inputs

t0        (1,:)  Time series (s)

Outputs

t         (1,:)  Time series (new units)
u         (1,:)  Label string, 'Time = (units)'
s         (1,:)  Units string
f         (1,:)  Time scale factor, t = t0/f

◆ TimeLabl()

function TimeLabl ( in  t0,
in  dT 
)

Generates a time label given the maximum value of t and rescales t.

If two arguments are entered it computes the time series t as

t = (0:(nSim-1))*dT

The available units are (years,months,weeks,days,hours,minutes,seconds) Years and months are mean.


Form

[t, c, u, s] = TimeLabl( t0 )
[t, c, u, s] = TimeLabl( nSim, dT )


Inputs

t0      (1,:)  Time (sec)
  • or -
nSim    (1,1)  Number of time steps
dT      (1,1)  Time step (sec)

Outputs

t            (1,:) Time (new units)
c            (1,:) Label string, 'Time = (units)' 
u      (1,:) Units of time
s      (1,1) Time scale factor, t = t0/s

◆ TimePlugIn()

function TimePlugIn ( in  action,
in  modifier,
in  hFig,
in  position,
in  callback 
)

Create a time GUI plug in.

To set the time plugin:
TimePlugIn( 'set',  h.timePlugInTag, struct( 'jDEpoch', 2.45162380976e+06, 
'duration', '01:00:00', 'dT', 0.25 ) );  


Typing TimePlugIn is the same as TimePlugIn('initialize')

Form

x =  TimePlugIn( action, modifier, hFig, position, callback )


Inputs

action      (1,:)  Action 'initialize', 'update'
modifer     (1,:)  Modifier to the action or data structure if intialization
hFig        (1,1)  Handle to the figure or if 'update' radio button handles
position    (1,4)  [left bottom width height]
callback    (1,:)  Callback string when something has changed in this gui

Outputs

x           (1,1)  The tag if action is 'initialize'

◆ TimeStringToJD()

function TimeStringToJD ( in  s)

Convert a time string to Julian date.

The time string

must be in the form 00:00:00.

Type TimeStringToJD for a demo.


Form

jD = TimeStringToJD( s )


Inputs

s             (1,:)   String 'hh:mm:dd'

Outputs

jD            (1,1)   Julian Date   

◆ TimeToGo()

function TimeToGo ( in  totalSteps,
in  stepsDone,
in  tToGoMem,
in  rRT,
in  dT 
)

Computes the time left to go in the simulation, the predicted finish.

time and the ratio of simulation time to real time. This routine should be called at regular intervals.


Form

[ rRT, tToGoMem, tToGo, tDone ] = TimeToGo( totalSteps, stepsDone, tToGoMem, rRT, dT )


Inputs

totalSteps             Total number of steps in the simulation
stepsDone              Number of steps completed
tToGoMem               Memory [lastJD, lastStepsDone, number of averages done]
rRT                    Ratio of simulation time to real time
dT                     Simulation time step (sec)           

Outputs

rRT                    Ratio of simulation time to real time
tToGoMem               Memory [lastJD, lastStepsDone, number of averages done]
tToGo                  Time left in the simulation
tDone                  Predicted clock time of finish

◆ TitleS()

function TitleS ( in  x,
in  font 
)

Creates a title using the toolbox style settings.

x can be entered as 'text@fontName' to get a different font.


Form

TitleS( x, font )


Inputs

x          (:)    Text
font       (1,:)  Font name

Outputs

None

◆ Torus()

function Torus ( in  c,
in  r,
in  n,
in  c2,
in  nuX 
)

Draws a torus.

Draws a torus


Form

[v, f] = Torus( c, r, n, c2, nuX )


Inputs

c   (1,1) Major radius
r   (1,1) Minor radius
n   (1,1) Number of divisions
c2  (1,1) Radius for the cut
nuX (1,1) Angular range of the minor angle 

Outputs

v   (n,3)   Vertices
f   (n,3)   Faces

◆ TranslateAxes()

function TranslateAxes ( in  i,
in  r,
in  m,
in  sgn 
)

Recompute the moment of inertia "i" by translating axes.

There are two cases:
- translating the origin by "r", body has mass "m"
- adding a point mass "m" at location "r" from the origin

Form

i = TranslateAxes( i, r, m, sgn )


Inputs

i          (3,3)      Original Moment of Inertia
r          (3,1)      Translation vector
m           (1)       Mass of body
sgn         (1)       Sign of inertia change.
+1 Positive if point mass added
or if origin moved away from CG
-1 Negative if origin moved towards CG

Outputs

i          (3,3)      New Moment of Inertia

◆ TreeDiagram()

function TreeDiagram ( in  n,
in  w,
in  update,
in  withTrackIDs 
)

Generates a tree diagram.

Type TreeDiagram for a demo. w is optional the defaults are:

.name      = 'Tree';
.width     = 400;
.fontName  = 'Times';
.fontSize  = 10;
.linewidth = 1;
.linecolor = 'r';

Form

TreeDiagram( n, w, update, withTrackIDs )


Inputs

n        {:}    Nodes
.parent     (1,1) Parent
.name       (1,1) Number of observation
.scan       (1,1) Scan number
w        (1,1)  Diagram data structure
.name      (1,:) Tree name
.width     (1,1) Circle width
.fontName  (1,:) Font name
.fontSize  (1,1) Font size
update   (1,1)  If entered update an existing plot

Outputs

None

◆ TResp()

function TResp ( in  g,
in  x0,
in  u,
in  dT,
in  T 
)

Compute the time response of a state-space system.

Type TResp for a demo.

Form

[x,y,t,u] = TResp( g, x0, u, dT, T );


Inputs

g           (.)     Statespace object
x0          (nS,1)  Initial state
u           (nI,:)  Input control vector
dT          (1,1)   Time step [sec]
T           (1,1)   Final time [sec]   (optional)

Outputs

x          (nS,:)     State trajectory
y          (nO,:)     Output trajectory
t          (1,:)      Time history       [sec]
u          (nI,:)     Input control vector

◆ Triangle()

function Triangle ( in  x,
in  y,
in  z,
in  mass 
)

Generate a solid triangle.

This function will compute the mass properties data structure if a mass is entered. Type Triangle for a demo.


Form

[v, f, m] = Triangle( x, y, z, mass )


Inputs

x           (1,1) x length
y           (1,1) y length
z           (1,1) z length
mass        (1,1) mass

Outputs

v           (:,3) Vertices
f           (:,3) Faces
m           (.)   Mass data structure

See also Volumes, Inertias, DrawVertices


◆ TriangularTruss()

function TriangularTruss ( in  x1,
in  x2,
in  d,
in  n 
)

Generate a triangular truss going from x1 to x2.

The truss is inscribed in a circle of radius d. If n is omitted n = 10.

Type TriangularTruss for a demo.


Form

[v, f, l] = TriangularTruss( x1, x2, ds, n )


Inputs

x1         (3,1) Location of top
x2         (3,1) Location of bottom
d          (1,1) Diameter
n          (1,1) Number of divisons 

Outputs

v         (:,3)  Vertices
f         (:,3)  Faces
l         (1,1)  Total length of the truss elements

◆ TrnsZero()

function TrnsZero ( in  a,
in  b,
in  c,
in  d 
)

Computes the transmission zeros of a plant.

For continuous time systems.

Form

z = TrnsZero( a, b, c, d )



Inputs

a                   Plant matrix
b                   Input matrix
c                   Measurement matrix
d                   Input feedthrough matrix

Outputs

z                   Transmission zeros

References: Maciejowski, J.M., Multivariable Feedback Design, Addison-Wesley, 1989, pp. 386-389.


◆ Truss()

function Truss ( in  x1,
in  x2,
in  w,
in  n,
in  wBar 
)

Generate a square truss going from x1 to x2.

If n is omitted n = 10. wBar is optional and is the width of the struts. Note that 2D trusses will not work properly if exported as OBJ files.

Type Truss for a demo of a truss with 3D struts.


Form

[v, f, l] = Truss( x1, x2, w, n, wBar )


Inputs

x1         (3,1) Location of top
x2         (3,1) Location of bottom
w          (1,1) Width
n          (1,1) Number of divisions
wBar       (1,1) Bar width

Outputs

v         (:,3)  Vertices
f         (:,3)  Faces
l         (1,1)  Total length of the truss elements

◆ TT2TAI()

function TT2TAI ( in  tT)

Converts Terrestrial (dynamic) time to Terrestrial atomic time.


Form

tAI = TT2TAI( tT )


Inputs

tdt   (:,:)  Terrestrial (dynamic) time

Outputs

tAI   (:,:)  Terrestrial atomic time

◆ TT2TDB()

function TT2TDB ( in  tT,
in  jD 
)

Converts terrestrial dynamic time to barycentric dynamical time.

If jD is not entered it will use the clock Julian Date.


Form

tDB = TT2TDB( tT, jD )


Inputs

tT       (:,:) Terrestrial (dynamic) time
jD       (:,:) Julian date (days)

Outputs

tDB      (:,:) TTerrestrial dynamic barycenter time

◆ TT2UT1()

function TT2UT1 ( in  jDTT)

Converts TT (Terrestrial (dynamic) Time) to UT1.

Time scale based on the rotation of the earth) UT1 = TT - DT where DT is determined from astronomical observations.


Form

jDUT1 = TT2UT1( jDTT )


Inputs

jDTT      (1,1) Julian date Terrestrial (Dynamic) Time

Outputs

jDUT1     (1,1) Julian date Universal Time 1

◆ TTPlots()

function TTPlots ( in  mag,
in  w,
in  t,
in  gU,
in  title 
)

Generates torque transmission plots.

Inputs are magnitude vectors and frequency vectors.


Form

TTPlots( mag, w, t, gU, title )


Inputs

mag            (n,m)  Magnitude vectors
w              (1,m)  Frequency vector
t              (n,p)  Titles (strings)
gU                    Gain units (string)
title                 Page title

Outputs

None                  

◆ Tube()

function Tube ( in  rO,
in  rI,
in  l,
in  n 
)

Generate a tube with specified inner and outer wall, and length.

The origin is at the bottom. Type Tube for a demo.


Form

[v, f] = Tube( rO, rI, l, n )


Inputs

rO  (1,1) Outer radius
rI  (1,1) Inner radius
l   (1,1) Length
n   (1,1) Number of divisions

Outputs

v   (:,3) Vertices
f   (:,3) Faces

◆ TubeArc()

function TubeArc ( in  rO,
in  rI,
in  l,
in  arc,
in  n 
)

Generate a portion of a tube with an inner and outer wall.

The top and bottom radii may be different. The origin is at the bottom. This function will not work correctly for a full tube. Use Tube for that purpose.

Type TubeArc for a demo.


Form

[v, f] = TubeArc( rO, rI, l, n )


Inputs

rO  (1,2) Outer radius [top, bottom]
rI  (1,2) Inner radius [top, bottom]
l   (1,1) Length
arc (1,2) Arc [beginning end] (rad)
n   (1,1) Number of divisions

Outputs

v   (:,3) Vertices
f   (:,3) Faces

◆ TubeSection()

function TubeSection ( in  rO,
in  rI,
in  l,
in  ang1,
in  ang2,
in  n 
)

Generate a tube with specified inner and outer wall, and length.

The origin is at the bottom. Type Tube for a demo.


Form

[v, f] = TubeSection( rO, rI, l, ang1,ang2, n )


Inputs

rO    (1,1) Outer radius
rI    (1,1) Inner radius
l     (1,1) Length
ang1  (1,1) Start angle
ang2  (1,1) End angle
n     (1,1) Number of divisions

Outputs

v     (:,3) Vertices
f     (:,3) Faces

◆ TubeWithBends()

function TubeWithBends ( in  r,
in  p,
in  nB,
in  nC 
)

Generate a tube with bends.

If nB is zero it will not smooth the bends.

Type TubeWithBends for a demo.


Form

[v, f] = TubeWithBends( r, p, nB, nC )


Inputs

r     (1,1) Radius of the tube
p       (3,:) Location of center points
nB      (1,1) Number of divisions at bends (should be odd)
nC    (1,1) Number of circumferential divisions

Outputs

v     (:,3) Vertices
f     (:,3) Faces

◆ Tubing()

function Tubing ( in  p,
in  d,
in  n 
)

Generate a tube through the points p.

If n is omitted n = 3. Type Tubing for a demo.


Form

[v, f, l] = Tubing( p, d, n )


Inputs

p          (3,:) Points through which the tube must pass
d          (1,1) Diameter
n          (1,1) Number of divisons 

Outputs

v         (:,3)  Vertices
f         (:,3)  Faces
l         (1,1)  Total length of the tubing elements

◆ U2Q()

function U2Q ( in  u,
in  v 
)

Finds the quaternion that aligns a unit vector with a second vector.

Type U2Q for a demo.


Form

q = U2Q( u, v )


Inputs

u                   (3,:)    Vector
v                   (3,:)    Where vector is after rotation

Outputs

q                   (4,:)    Quaternion that rotates u into v

◆ UChannel()

function UChannel ( in  x,
in  y,
in  z,
in  t,
in  d,
in  b 
)

Generate a box with a u cut at the +x end.

Type UChannel for a demo. With no outputs UChannel will draw your object.


Form

[v, f] = UChannel( x, y, z, t, d, b )


Inputs

x           (1,1)  x length
y           (1,1)  y length
z           (1,1)  z length
t           (1,1)  Flange thickness
d           (1,1)  Depth of cut in x
b           (3,3)  Transformation matrix (Default is eye(3))

Outputs

v           (16,3) Vertices
f           (12,3) Faces

◆ UDKalmanFilter()

function UDKalmanFilter ( in  action,
in  d,
in  z 
)

Implements a Kalman filter using UD factorization.

First call

d = UDKalmanFilter( 'p to ud', p )

You need to add r, q, h, and x to d. Then call

loop:

d = UDKalmanFilter( 'incorporate measurement', d, z ) d = UDKalmanFilter( 'propagate', d ) end


Form

d = UDKalmanFilter( action, d, z )


Inputs

action    (1,:)   Action to perform
d         (1,1)   Data structure
.u   Upper triangular portion of the covariance matrix
.r   Measurement noise scalar
.q   State noise matrix
.h   Measurement equation
.x   State
.k   Gain (computed)
z         (n,1)   Measurement(s)

Outputs

y         (:)     Depends on the action

References: Bierman, G. J. (1977) Factorization Methods for Discrete Sequential Estimation. Academic Press.


◆ UIElement()

function UIElement ( in  varargin)

Interface to PSS and Mathworks UI.

PSS functions

editpm Edit box with a + and - button list Two dimensional scrollable list of uicontrols checkboxlist List of checkboxes listwithbutton Listbox with a button. You need to supply two

callbacks, callback.button and callback.list datastructurelist Draw a datastructure

Examples - see also UIElementDemo

datastructurelist

h = UIElement( 'parent', h.fig, 'height', 60, 'position', p,...

'width', 180, 'style', 'datastructurelist', 'datastructure', d );


Form

h = UIElement( varargin )


Inputs

varargin {}     Variable input arguments

Outputs

h              (:)    Handle

◆ UKF()

function UKF ( in  action,
in  d,
in  y,
in  verbose 
)

Implement an Unscented Kalman Filter.

The filter uses numerical integration to propagate the state. The filter propagates sigma points, points computed from the state plus a function of the covariance matrix. For each state there are two sigma states.

The default integrator is RK4, or you cab specify an integrator with the field

d.integrator = @myIntegratorName

To initialize UKF call

d = UKF( 'initialize', d );

To update

d = UKF( 'update', d, y );

The filter appends internal data to the data structure. d.x gives the current estimated state and d.pXX the state covariance.

The measurement function is of the form

meas = MeasFun( x, dMeasFun );

The state function is of the form

xDot = StateFun( x, t, dStateFun );

You can use either the Cholesky transform or matrix square root to form the sigma points.


Form

d = UKF( action, d, y )
d = UKF( 'datastructure', nStates, nMeas )


Inputs

action    (1,:)  'initialize' or 'update' or 'datastructure'
d          (.)  UKF data structure
.rHSFun        (1,:) Name or handle of RHS function
.integrator    (1,:) Handle of integrator function
.rHSFunData   (.)   RHS function data structure
.measFun       (1,:) Handle of measurement function
.measFunData      (.)   Measurement function data 
.x             (n,1) Initial state vector
.p             (n,n) Covariance matrix for x   
.pXX           (n,n) Covariance after state update
.dY            (1,1) Number of measurements        
.dX            (1,1) Number of states        
.rP            (n,n) Process noise covariance        
.rM            (n,n) Measurement noise covariance
.alpha         (1,1) Scaling 1e-4 <= alpha <= 1
.kappa         (1,1) Secondary scaling usually 0
.beta          (1,1) Prior knowledge of distribution = 2
for Gaussian distributed noise
.dT            (1,1) Time step
.t             (1,1) Time
.sigmaPtAlg    (1,1) 1 = sqrtm, 2 = chol
y         (m,1)  Measurement vector
verbose   (1,1)  Flag for verbose output. 1 = warn, 2 = error.

Outputs

d          (.)   UKF data structure with the following appended
.dX          (1,1) Number of states
.n           (1,1) Number of sigma points
.y           (m,1) Measurements based on the states
.xA          {n}   Sigma points
.pP          (n,n) Covariance matrix prior to
measurement
.xP          (n,1) State vector prior to measurement
incorporation
.res         (:,1) Residuals

References: Voss, H. U., Timmer, J., Kurths, J., "Nonlinear Dynamical System Identification from Uncertain and Indirect Measurements," International Journal of Bifurcation and Chaos, Vol. 14, No. 6, 2005, pp. 1905-1933. Van der Merwe, R. and Wan, E., "Sigma-Point Kalman Filters for Probabilistic Inference in Dynamic State-Space Models",


◆ UKFP()

function UKFP ( in  action,
in  d,
in  y 
)

Implement an Unscented Kalman Filter for parameter estimation.

The filter uses numerical integration to propagate the state. The filter propagates sigma points, points computed from the state plus a function of the covariance matrix. For each parameter there are two sigma parameters. The current estimated state must be input each step.

The filter appends internal data to the datastructure

To initialize call

d = UKFP( 'initialize', d );

To update

d = UKFP( 'update', d, y );

Form

d = UKFP( action, d, y )


Inputs

action    (1,:)  'initialize' or 'update'
d          (.)   UKFP data structure
.rHSFun      (1,:) Name of RHS function
.rHSFunData  (1,1) RHS function data structure
.measFun     (1,:) Name of measurement function
.measFunData (1,1) Measurement function data 
.x           (:,1) State vector
.p           (n,n) Covariance matrix for w   
.rP          (n,n) Plant noise covariance 
.rY          (m,m) Measurement noise covariance
.alpha       (1,1) Scaling parameter (1e-4 to 1)
.beta        (1,1) Scaling parameter (usually 2)
.kappa       (1,1) Scaling parameter (usually 0) 
.w           (n,1) Parameters      
y         (m,1)  Measurement vector

Outputs

d          (.)   UKFP data structure with the following appended
.n           (1,1)   Twice the number of states + 1
.y           (m,1)   Measurements based on the states
.wA          {n}     Sigma points
.wC          (1,n+1) Weights
.wM          (1,n+1) Weights
.gamma       (1,1)   Sigma points scaling parameter
.lambda      (1,1)   Sigma points scaling parameter
.pDD         (m,m)   Measurement covariance
.pWD         (n,m)   Parameter, measurement cross
covariance
.D           (n,2*n) Measurements at sigma points
.dY          (n,1)   Residuals
.L           (1,1)   Number of parameters

References: Van der Merwe, R. and Wan, E., "Sigma-Point Kalman Filters for Probabilistic Inference in Dynamic State-Space Models". Matthew C. VanDyke, Jana L. Schwartz, Christopher D. Hall, "UNSCENTED KALMAN FILTERING FOR SPACECRAFT ATTITUDE STATE AND PARAMETER ESTIMATION,"AAS-04-115.


◆ UKFPredict()

function UKFPredict ( in  d)

Unscented Kalman Filter state prediction step.

This uses RK4 to propagate the state.

Use d = UKFWeight( d ) to get the weight matrices.

The function f is of the form f(x,t,d) where d is a data structure contained in fData.


Form

d = UKFPredict( d )


Inputs

d   (1,1)  UKF data structure
.m       (n,1)       Mean
.p       (n,n)       Covariance
.q       (n,n)       State noise
.wM      (1,2n+1)    Model weights
.w       (2n+1,2n+1)    Weight matrix
.f       (1,:)       Pointer for the right hand side
function
.fData   (1,1)       Data structure with data for f
.dT      (1,1)       Time step
.t       (1,1)       Time

Outputs

d   (1,1)  UKF data structure
.m       (:,1)       Mean
.p       (:,:)       Covariance

◆ UKFRTSS()

function UKFRTSS ( in  m,
in  p,
in  d 
)

Rauch-Tung-Striebel smoothing for an Unscented Kalman Filter.

This is for a non-augmented, i.e. additive Gaussian noise form. This assumes a model of the form:

x = f(x,q) y = h(x,r)

You pass the data structure that was already generated by an Unscented Kalman Filter and the results of the predict and update steps.


Form

d = UKFRTSS( m, p, d )


Inputs

m   (n,:)   Means
p   (n,n,:) Covariance
d   (1,1)   UKF data structure
.m       (n,1)          Mean
.p       (n,n)          Covariance
.q       (n,n)          State noise
.wM      (1,2n+1)       Model weights
.w       (2n+1,2n+1)    Weight matrix
.f       (1,:)          Name of right hand side
.fData  (1,1)           Data structure with data for f
.dT      (1,1)          Time step
.t       (1,1)          Time

Outputs

d   (1,1)   UKF data structure
.mS      (:,1)          Mean smoothed
.pS      (:,:)          Covariance smoothed

◆ UKFUpdate()

function UKFUpdate ( in  d)

Unscented Kalman Filter measurement update step.

The kMeas field is a list of measurement sets (i.e. measurement functions) to use.


Form

d = UKFUpdate( d )


Inputs

d   (.)    UKF data structure
.m       (:,1)  Mean
.p       (:,:)  Covariance
.h       {}    Measurement function pointers
.hData   {}    Measurement function data
.kH      (1,:)  Which measurements are in y
.r       {}    Measurement covariance matrices
.y       (1,1)  Measurement data structure
.data   (m,1) Measurements
.param  (1,1) Parameter data structure
.hFun  (1,:) Measurement function pointer
.hData (1,1) Measurement function data structure
.r     (m,m) Measurement covariance
.w       (:,:)  Weighting matrix
.wM      (:,1)  Weights
.kMeas   (1,:)  Measurement sets to use.

Outputs

d   (1,1)  UKF data structure
.m       (:,1)  Mean
.p       (:,:)  Covariance
.v       (m,1)  Residuals

◆ UKFUT()

function UKFUT ( in  m,
in  p,
in  c,
in  wM,
in  w,
in  fun,
in  dFun 
)

Unscented Kalman Filter transform.

This can be used for the measurements or the states. The weight matrix is used by the matrix form of the unscented transform.

The functions fun are passed as pointers and are of the form

MyFunction( x, d )

where x is an n by 2*n matrix of states or measurements. d is a data structure. If the unscented transform is used for states, fun propagates the states. For measurements it computes the measurements. The weighting factors are computed by UKFWeight.


Form

[mU, sU, cU] = UKFUT( m, p, c, wM, w, fun, dFun )


Inputs

m             (n,1)         Means
p             (n,n)         Covariance matrix
c             (1,1)         Scaling constant
wM            (1,2*n)       Weighting array
w             (2*n+1,2*n+1) Weighting matrix
fun           (1,:)         Function pointer for processing x
dFun          (1,1)         Data structure to pass to fun

Outputs

mU            (2*n+1,2*n+1) State matrix
sU            (2*n+1,2*n+1) Correlation matrix
cU            (2*n+1,2*n+1) Cross-correlation matrix

◆ UKFWeight()

function UKFWeight ( in  d)

Unscented Kalman Filter weights.

The weight matrix is used by the matrix form of the Unscented Transform. Both UKSPredict and UKSUpdate use the data structure generated by this function.

The constant alpha determines the spread of the sigma points around x and is usually set to between 1e-3 and 1. beta incorporastes prior knowledge of the distribution of x and is 2 for a Gaussian distribution. kappa is set to 0 for state estimation and 3 - number of states for parameter estimation.


Form

[w, wM, wC, c] = UKFWeight( d )


Inputs

d   (1,1)   Data structure with constants
.kappa  (1,1)   0 for state estimation, 3-#states for 
parameter estimation
.m      (:,1)   Vector of mean states
.alpha  (1,1)   Determines spread of sigma points
.beta   (1,1)   Prior knowledge - 2 for Gaussian

Outputs

d   (1,1)   Data structure with constants
.w      (2*n+1,2*n+1)   Weight matrix
.wM     (1,2*n+1)       Weight array
.c      (1,1)           Scaling constant
.lambda (1,1)           Scaling constant

◆ UKUDF()

function UKUDF ( in  action,
in  d,
in  y 
)

Implement an Unscented Kalman Filter in UD (upper diagonal) form.

The filter uses numerical integration to propagate the state. The filter propagates sigma points, points computed from the state plus a function of the covariance matrix. For each state there are two sigma states.

The filter appends internal data to the datastructure

To initialize call

d = UKUDF( 'initialize', d );

To update

d = UKUDF( 'update', d, y );

d.x gives the current estimated state and d.pXX the state covariance.

The measurement function is of the form

meas = MeasFun( x, dMeasFun );

The state function is of the form

xDot = StateFun( x, t, dStateFun );

Form

d = UKUDF( action, d, y )


Inputs

action    (1,:)  'initialize' or 'update'
d         (1,1)  UKF data structure
.rHSFun      (1,:) Name of RHS function
.rHSFunData  (1,1) RHS function data structure
.measFun     (1,:) Name of measurement function
.measFunData (1,1) Measurement function data 
.x           (n,1) Initial state vector
.p           (n,n) Covariance matrix for x   
.dY          (1,1) Number of measurements        
.L           (1,1) Number of states        
.rP          (n,n) Process noise covariance        
.rM          (n,n) Measurement noise covariance
.alpha       (1,1) Scaling 1e-4 <= alpha <= 1
.kappa       (1,1) Secondary scaling usually 0
.beta        (1,1) Prior knowledge of distribution = 2
for Gaussian distributed noise
.dT          (1,1) Time step
.t           (1,1) Time
y         (m,1)  Measurement vector

Outputs

d         (1,1)  UKF data structure with the following appended
.L          (1,1) Number of states
.n           (1,1) Twice the number of states
.y           (m,1) Measurements based on the states
.xA          {n}   Sigma points

References: Voss, H. U., Timmer, J., Kurths, J., "Nonlinear Dynamical System Identification from Uncertain and Indirect Measurements," International Journal of Bifurcation and Chaos, Vol. 14, No. 6, 2005, pp. 1905-1933.

Van der Merwe, R. and Wan, E., "The Square-Root Unscented Kalman
Filter for State and Parameter Estimation".

◆ UnitVectorFromOffset()

function UnitVectorFromOffset ( in  v1,
in  v2,
in  cone,
in  clock 
)

Computes a unit vector offset from v2 with origin at v1.

It creates a random coordinate system with v2-v1 as the +z axis.
cone is the angle from +z
clock is the angle from +x in the xy-plane. This function is useful
for creating a set of vectors but because the orientation of x and y
is random you cannot externally specify the clock angle definition.


Type UnitVectorFromOffset for a demo.

Forms: u = UnitVectorFromOffset u = UnitVectorFromOffset( v1, v2, cone ) u = UnitVectorFromOffset( v1, v2, cone, clock )



Inputs

v1            (3,1)        Origin 
v2            (3,1)        Vector from which the offset is calcuated
cone          (1,1)        Cone angle of the offset
clock         (1,1)        Clock angle of the offset

Outputs

u             (3,1)        Unit vector with offset

◆ UT12TT()

function UT12TT ( in  jDUT1)

Converts UT1 (time scale based on the rotation of the earth)

To Terrestrial Time (also known as TT or terrestrial (dynamic) time). UT1 = TT - DT where DT is determined from astronomical observations.


Form

jDTT = UT12TT( jDUT1 )


Inputs

jDUT1     (:,:) Julian date Universal Time 1

Outputs

jDTT      (:,:) Julian date Terrestrial (Dynamic) Time

◆ ValidTime()

function ValidTime ( in  t)

Returns the time if valid.

Otherwise returns empty. Valid time is in the for 00:00:00


Form

d = ValidTime( t )


Inputs

t             (1,:)   Date string

Outputs

d             {:}     Fraction of day

◆ VantagePoint()

function VantagePoint ( in  x,
in  y,
in  A,
in  g,
in  color 
)

Adds vantage points to an existing plot.

Color can be a character like 'k' for black or an array [r,g,b].


Form

VantagePoint( x, y, A, g, color )


Inputs

x       (1,:)   X points            
y       (1,:)   Y points            
A       (:,:)   Visibility matrix               
g       (2,1)   Reference points                
color   (1,:)   Line color default is green             

Outputs

None

◆ VCFlatFile()

function VCFlatFile ( in  fileName,
in  time,
in  varargin 
)

Write a set of variables to a VC flat file (comma-separated with header).

Assumes all variables have one dimension that matches the time vector, and it will tranpose all matrices as needed. The filename passed in should include the desired extension. The names of the input files are used in the header, so do not do a transpose of a variable in the call to this function, i.e.

VCFlatFile( fileName, time, theta, r' )  %% this will cause an error!

This file can be read into VC's default flat file reader. The matrices will automatically be reconstructed.

The file lookes like:

Time,theta,r,r,r
0,0,1,0,0,
1,0.1,0.995,0.1,0,
...

This example can be produced with the built-in demo. Type VCFlatFile for a demo.


Form

VCFlatFile( fileName, time, varargin )


Inputs :

filename    (:)       Full filename of output file.
time       (1,n)
args       (p,n)

◆ VelocityLabel()

function VelocityLabel ( in  v)

With an input in meters/s give a reasonable output scale.


Form

[v, s] = VelocityLabel( v )


Inputs

v            (1,:)  Velocity (m/s)

Outputs

v            (1,:) Velocity
s            (1,:) Label (m/s, km/s, au/day, 1/c)

◆ VFToMassStructure()

function VFToMassStructure ( in  v,
in  f,
in  d 
)

Computes mass properties for a component defined by vertices and faces.

Mass and inertia are scaled for a unitary areal mass. Appropriate for plates and membranes.


Form

mass = VFToMassStructure( v, f, d )
mass = VFToMassStructure( v, f )


Input

v               (:,3) Vertices
f               (:,3) Faces
d                (:)  Data structure (optional, see PolygonProps)
.a         (1,:)  Areas of the triangles
.r         (3,:)  Centroids of the triangles

Output

m              (1,1)   Structure
.mass     (1,1) Mass (area)
.inertia  (3,3) Inertia matrix
.cM       (3,1) Center of mass (centroid)

◆ View3D()

function View3D ( in  type)

View a plane of a 3D plot or standard cartesian view.

The default view is view(3).

View3D is the same as View3D('none')


Forms: View3D( 'xy' ) View3D( 'yz' ) View3D( 'xz' ) View3D( 'cart' )



Inputs

type     (:)    String indicating view type.

Outputs

none

◆ VM2Int()

function VM2Int ( in  v)

Converts apparent visual magnitude to intensity in watts/m^2.

The apparent visual magnitude of the Sun is -26.85.


Form

i = VM2Int( v )


Inputs

v                 (:)    Visual magnitude

Outputs

i                 (:)    Intensity (watts/m^2)

References: Berry, M. (1981). Principles of cosmology and gravitation. Cambridge University Press, Cambridge, England, 10.


◆ Volumes()

function Volumes ( in  x,
in  type 
)

Computes volumes of common objects about their c.m.

All objects have their axis of symmetry about z. If you enter a thickness with 'cylinder', 'box' or 'sphere' it will automatically compute the hollow versions. The 'cylindrical end caps' type has spherical end caps with the given radius.


Form

vol = Volumes( x, type)


Inputs

x                  Relevant dimensions
type             Type of solid
'sphere'           x = [radius]
'cylinder'         x = [radius, zLength] 
'box'              x = [xLength, yLength, zLength]
'ellipsoid'        x = [a b c]
'plate'            x = [xLength, yLength]
'disk'                 x = [radius, thickness]
'hollow cylinder'  x = [outer radius, zLength, thickness]
'hollow box'       x = [xLength, yLength, zLength, thickness]
'hollow sphere'    x = [radius, thickness]
'torus'            x = [R major,r minor]
'elliptical torus' x = [R major,a minor,b minor]
'cone'             x = [radius,height]
'pyramid'          x = [base,height]
'cylindrical end caps'   x = [radius,length]

Outputs

vol     (1,1)  Volume

◆ WaitBarManager()

function WaitBarManager ( in  action,
in  d 
)

Manages the wait bar.

WaitBarManager( 'initialize', struct('nSamp',10,'name','Name') ); WaitBarManager( 'update', 3 ); WaitBarManager( 'close' );


Form

WaitBarManager( action, d )


Inputs

action        (1,:)   Action 'initialize', 'update', 'close'
d             (1,1)   Input

Outputs

None   

◆ Watermark()

function Watermark ( in  string,
in  fig,
in  pos,
in  color 
)

Add a watermark to a figure.

This function creates two axes, one for the image and one for the text. Calling it BEFORE plotting can cause unexpected results. It will reset the current axes after adding the watermark. The default position is the lower left corner, (2,2).

Leaving out the color input will cause the logo to use the color of the figure for the background. You can set a default color to a persistent variable using the second form; clear the function to reset it.


Form

Watermark( string, fig, pos, color  )
Watermark( color ), set a temporary background color
Watermark( false ), turn watermarks off


Inputs

string     (1,:) Name, i.e. product name
fig        (1,1) Figure hangle
pos        (1,2) Coordinates, (left, bottom)
color      (3,1) Background color, [R G B]

Outputs

none

◆ Wedge()

function Wedge ( in  x1,
in  x2,
in  w,
in  t 
)

Generate a wedge between x1 and x2.

x1 and x2 are on the x-axis. Type Wedge for a demo.


Form

[v, f] = Wedge( x1, x2, w, t )


Inputs

x1          (1,1)  Tip position
x2          (1,1)  Thick end
w           (1,1)  Width in y direction
t           (1,1)  Thickness in z

Outputs

v           (6,3) Vertices
f           (8,3) Faces

◆ Windup()

function Windup ( in  a,
in  b,
in  c,
in  d,
in  p,
in  sType 
)

Implements anti windup compensation.

Given a state space system


y[k]   = C*x[k] + D*u[k]                        (1)
x[k+1] = A*x[k] + B*u[k]                        (2)


Implements anti windup compensation. This casts the system in the
form


y[k]   = sat( C*x[k] + D*u[k] )                 (3)
x[k+1] = (A-L*C)*x[k] + (B-L*D)*u[k] + L*y[k]   (4)



{a,b,c,d} may also be in delta form.

Form

[a, b, l] = Windup( a, b, c, d, p, sType )


Inputs

a                    Controller state transition matrix
b                    Controller input matrix
c                    Controller state output matrix
d                    Controller feedthrough matrix
p                    Eigenvalues
sType                State equation type ('Delta' or 'Z')

Outputs

a                    Plant matrix
b                    Input matrix
l                    Output matrix

◆ WPZ()

function WPZ ( in  a,
in  b,
in  c,
in  d,
in  n,
in  iu,
in  iy 
)

Frequency vector with complex poles and zeros.

This routine produces a frequency vector that includes all of the
complex poles of the system and all complex zeros of each channel.
This vector is useful for frequency response calculations.

Form

w = WPZ( a, b, c, d, n, iu, iy )
w = WPZ( num, den, n )


Inputs

a                   Plant matrix or numerator polynomials
b                   Input matrix or denominator polynomials
c                   Measurement matrix
d                   Input feedthrough matrix
n                   Number of frequency points
iu                  Inputs  ( = 0, or leave out for all)
iy                  Outputs ( = 0, or leave out for all)

Outputs

w                   Frequency vector

◆ WReson()

function WReson ( in  lmin,
in  lmax,
in  n,
in  w 
)

Creates a frequency vector with points around resonances.

The resonances are specified in the vector w. 
Only complex values of w will be used.
Those with negative imaginary parts will be
ignored. Thus you can enter the output of eig as an input
to this function.

Form

wV = WReson( lmin, lmax, n, w )


Inputs

lmin                Log of minimum frequency
lmax                Log of maximum frequency
n                   Number of logarithmically spaced points
w                   Resonances (complex) 

Outputs

wV                  Frequency vector

◆ WriteCM()

function WriteCM ( in  fID,
in  matName,
in  m,
in  x,
in  nD,
in  nT,
in  nPR 
)

Write a matrix for use in a C or C++ program.


Form

WriteCM( fID, matName, m, x, nD, nT, nPR )


Inputs

fID                      File id
matName                  Name of matrix for comment in C code
m                        Name of matrix for C code
x                        The matrix
nD                       Number of decimal places
nT                       Number of characters total
nPR                      Number per row (default is 3 for
matrices and 1 for vectors);

Outputs

none

◆ XLabelS()

function XLabelS ( in  x,
in  font 
)

Creates an xlabel using the toolbox style settings.

x can be entered as 'text@fontName' to get a different font.


Form

XLabelS( x, font )


Inputs

x          (:)    Text
font       (1,:)  Font name

Outputs

None

◆ YLabelS()

function YLabelS ( in  x,
in  font 
)

Creates a ylabel using the toolbox style settings.

x can be entered as 'text@fontName' to get a different font.


Form

YLabelS( x, font )


Inputs

x          (:)    Text
font       (1,:)  Font name

Outputs

None

◆ YPF2T()

function YPF2T ( in  y)

Converts years in fractional form, e.g.

1993.5 to T


Form

T = YPF2T( y )


Inputs

y       (1,1) Year in fractional form

Outputs

T       (1,1) Julian centuries of 86400s dynamical time from j2000.0

◆ Z2Damp()

function Z2Damp ( in  z,
in  T 
)

Z domain to s domain damping and natural frequency.

Computes the damping ratio and natural frequency for a set of eigenvalues of a discrete time plant.


Form

[zeta, w, wr, s] = Z2Damp( z, T )



Inputs

z                   Points in the z-plane
T                   Sampling period

Outputs

zeta                Damping ratio
w                   Natural frequency
wr                  Resonant frequency
s                   Equivalent s-plane poles

◆ Z2S()

function Z2S ( in  f,
in  g,
in  h,
in  j,
in  dT,
in  sType 
)

Transform an z-plane transfer function into the s-plane.

If only 3 inputs are given it assumes the input is in transfer
function form. Otherwise it assumes state equation form.

Form

[a, b, c, d] = Z2S( f, g, h, j, dT, sType )       
[nums, dens] = Z2SBl( numz, denz, dT, sType )


Inputs

f                  Discrete state matrix or numerator polynomial
g                  Discrete input matrix or denominator polynomial
h                  Output matrix
j                  Feedthrough matrix
T                  Sampling period
sType              'bilinear', 'zoh', 'forward', 'backward'

Outputs

a                  State matrix or nums
b                  Input matrix or dens
c                  Output matrix or T
d                  Feedthrough matrix

References: Franklin, G.F., J.D. Powell, M.L. Workman, Digital Control of Dynamic Systems, 2nd Edition, Addison-Wesley, 1990, p. 137-147.


◆ ZFresp()

function ZFresp ( in  num,
in  den,
in  n 
)

Generates the frequency response for a digital filter.

-1               -nb
b(1) + b(2)z   + Š + b(nb+1)z
H(z) = ---------------------------------
-1               -na
a(1) + a(2)z   + Š + a(na+1)z


The routine interprets your input as follows:
If only 2 arguments are input it computes the frequency response
for 0 to ¼ at 512 points.


If 3 arguments are entered and the third is a scalar it will
interpret n as follows:


if ( n > 2.25 ),
do n point response between 0 and ¼
else if ( n < 2.25),
if n is an integer do an n point response between 0 and ¼
else
treat n as a scalar frequency
end
end


if 4 arguments are entered it will do an n point response between
0 and 2.25.

Form

[h, w] = ZFresp( num, den, n )


Inputs

num                 Numerator polynomial
den                 Denominator polynomial
n                   Number of points

Outputs

h                   Complex output vector
w                   Frequency points 

◆ ZLabelS()

function ZLabelS ( in  x)

Creates a zlabel using the toolbox style settings.


Form

ZLabelS( x )


Inputs

x          (:)    Text

Outputs

None

◆ ZOH()

function ZOH ( in  T,
in  n 
)

Create a model of a zero-order-hold using Padé approximants.

The ZOH will be scaled by 1/T as if it had a sampler in the
loop.

Form

[a, b, c, d] = ZOH( T, n )
[num, den]   = ZOH( T, n )


Inputs

T                   Hold period
n                   Number of terms (optional)

Outputs

a or num            Numerator polynomial or plant matrix
b or den            Denominator polynomial or input matrix
c                   Measurement matrix
d                   Feedthrough matrix