# Math Module ## Directory List

### AStar

 AStarSearch Finds the optimal path using A*. DeltaAngleForNewRADec Compute the angle change needed to change a trajectory so that it GenerateGrid Generate a grid on a sphere GlobeGrid Generate right ascensions and declinations for a global grid. GridPathCost Finds the cost for going from startNode to nextNode. GridSuccessorNodes Finds successor nodes in a square grid. GridTraverseCost Finds the cost of going from one node to another in a square grid. ManeuverCost Finds the cost for going from startNode to nextNode. ManeuverCost3D Finds the cost for going from startNode to nextNode in 3D. ManeuverSuccessorNodes Finds successor nodes. ManeuverSuccessorNodes3D Finds successor nodes in 3D. SphericalGrid Generate a grid on a sphere that is evenly spaced TransformGridCoordinates Transforms between 2D and 1D coordinates.

### Analysis

 Armijo Use the Armijo rule to compute a stepsize, alpha: AutoCorr Generates the autocorrelation function for the input sequence. Binomial The binomial expansion of (x + y)^n CFract Computes the value of a continued fraction of the form CHarm Generate a series of cosine harmonics of the arguments CHarmD Generate a series of cosine harmonics of the arguments DLyapG Find the solution for the Lyapunov equation apa' - p + q = 0 FitPair Given xF, find yF that best fits xF given the pair (x,y) FourierSeries Generates the Fourier series coefficients of a signal Heavisde Heavside function. H = 1 x  0, otherwise = 0 HypgF1 Computes the value of the hypergeometric function HypgFr Computes the value of the ratio of hypergeometric functions HypgMr Computes the value of the confluent hypergeometric ratio IntExpR One dimensional interpolation and extrapolation on the rows of a. IntExt One or two dimensional interpolation and extrapolation. Interp1D Performs a linear interpolation: InterpolateCircle Interpolates between x1 and x2 when x1 and x2 lie in a circle. When JCart2Sp Converts cartesian to spherical coordinates. JSp2Cart Jacobian for converting from spherical to cartesian coordinates Jacobian This function computes the Jacobian matrix for a right hand-side. JacobianODE This function computes the Jacobian matrix for a right hand-side. LogBaseN log of base n. Logistic Logistic function. LyapG Solve the general Lyapunov equation ap + pa' + q = 0 MakeDistribution Generate a list of random variables with some specified distribution NewStats Calculates the new standard deviation and average. NewtonsMethod Solve an optimization problem with Newton's method. OptimalTrajectory Optimal trajectory using simplex PAL Generates the Associated Legendre Functions of the first kind PDAL Generates Associated Legendre Functions of the first kind and derivatives PGauss Computes the Gaussian form of the Legendre functions. Pade Create a Padé approximant of exp(sT) SCHarm Generate a series of sine and cosine harmonics of the arguments SCHarmD Generate a series of sine and cosine harmonics of the arguments SCSeries Compute a series a + sum(bn sin(n wo t)) + sum(cn cos(n wo t)) SHarm Generate a series of sine harmonics of the arguments SHarmD Generate a series of sine harmonics of the arguments Simplex Uses the simplex method to minimize the cost when solving the problem Simplex2 Computes the solution to the simplex problem with an optional maximum constraint. SimplexOld Uses the simplex method to minimize the cost when solving the problem SimplexScaling Simplex slack variable scaling SphJacobian Spherical coordinates Jacobian SubPoly Subtract two polynomials so that c = a - b. WaveletMorlet Performs a wavelet transform using a Morlet Wavelet WorstFirstAssignment Reorder columns to minimize the diagonal sum with a worst-first policy

### Demos/AStar

 AStarSearch3DManeuverDemo Demonstrate A* for a close orbital maneuver. AStarSearchGrid1Demo Test AStarSearch using a grid with obstacles. AStarSearchGrid2Demo Test AStarSearch using a grid with more obstacles. AStarSearchManeuverDemo Demonstrate A* for a close orbital maneuver. AStarSearchOrderGridDemo Test AStarSearch using a grid with randomly placed obstacles. AStarSearchRandomGridDemo Test AStarSearch using a grid with randomly placed obstacles.

### Demos/Analysis

 SimplexConstraintRelaxationDemo Solve an infeasible LP with simplex through constraint relaxation SimplexScalingDemo Solve a linear program with Simplex. Illustrate the need for scaling. SimplexScalingDemoData.mat Example problem data THyperG Demonstrate hypergeometric functions.

### Demos/FDIR

 DCMotorSim Simulates 2 DC Motors with failure detection logic. DetectionFilterBuilderDemo Simulate a detection filter using the DetectionFilterBuilder GUI. FDIROLASim Test Fault Diagnosis using online approximators. OrbitFDIRDemo Demonstrate an orbit detection filter for a spacecraft with one thruster. OrbitFDIRPulseDemo Demonstrate an orbit detection filter with random thrust pulses. SpinnerFDIRDemo Demonstrate a detection filter for a spinning spacecraft.

### Demos/Probability

 DoggyProblem Demonstrate the BinomialTheorem for the doggy problem. GunProblem Demonstrate the BinomialTheorem for the gun problem.

### FDIR

 BuildLinearDF Create a detection filter for a fully measured system. DCMotorDetectionFilter Implements a DC motor detection filter. Uses Euler integration. DCMotorFailures Triggers a failure at time tFail. DCMotorParitySpace Computes the residuals for two DC motors. DetectionFilter Implement a detection filter for a fully measured system. DetectionFilterBuild Algorithm to compute detection filter gains. DetectionFilterBuilder GUI to build detection filters. DetectionFilterSimulation Simulate a detection filter using a state space model. DetectionFilterUnnormalized Create a unnormalized detection filter for a fully measured system. DualDCMotors Simulates two DC motors. FDIRTest.mat Sample data created by DetectionFilterBuilderDemo. NonlinearEstimator Implements an online approximator for a spring mass damper system. NonlinearSpring Right-hand-side of a nonlinear spring dynamics model. NonlinearSpringFault Nonlinear spring fault. NormalizeMatrix Normalizes a state space system for use with a detection filter. OnlineApproximator Implements an online approximator, f( y, theta ). ProbabilityOfFailure Computes the probability of failure. RadialBasisFunction Implements a radial basis function for online estimators. TMatrix Compute a transformation matrix from a statespace

### Geometry

 AngleSepFromRotation Compute angular separation between 2 vectors by rotating about an axis BilinearInterpolation Apply bilinear interpolation on 4 data points. FindValidAngleRange Find valid range of rotation angles that satisfy separation constraints FitEllipse Fit an ellipse. InsideAngleRange Determine whether an angle is inside an angular range. IntersectLineAndCone Compute the intersection of a line and a cone. IntersectLineAndEllipsoid Compute the intersection of a line and ellipsoid. MergeAngleRange Merge two angular ranges. Returns the intersection. Perpendicular Finds perpendicular vectors to a such that Dot(b,a) = 0. PointInGridInTriangle Determine whether points p are in triangle v. PointInPolygon Determine whether points p are in polygon v. PointInTriangle Determine whether points p are in triangle v. SegmentIntersection Compute whether and where two 2D line segments intersect SurfaceAreaEllipsoid Compute the surface area of an ellipsoid. UnitVectorAverage Average unit vector.

### Integration

 Euler EULER Euler's method for numerical integration. FracDI Fractional order derivative or integral RK2 Second order Runge-Kutta. RK4 Fourth order Runge-Kutta. Called function is of the form: RK45 Fourth/fifth order Runge-Kutta. RK4TI Fourth order Runge-Kutta integration. RHS is time-independent (TI). TwoDSimpsonIntegration Uses 2D Simpson's Rule to integrate an area.

### Linear

 BlockDiagonal Generate a block diagonal matrix ColCompR Computes the right column compression of a matrix. Compresses the ComplexToReal Convert a matrix from complex to real. Cross Vector cross product for multicolum arrays. DUnit Derivative of the unit vector for r. DelLZ Deletes leading zeros from a vector. Dot Dot product with support for arrays. DupVect Duplicate vector n times Factorl Computes the factorial matrix for a matrix. GJInv Matrix inverse using Gauss-Jordan elimination with partial pivoting. GenSub Subtract two matrices where NaN - NaN or inf - inf == 0 Inv3x3 Inverse of a 3x3 matrix. InvP The product form of the inverse IsSing Outputs 0 if the matrix is singular IsZero Set = 0 if the matrix is all zeros. LeastSq Weighted least squares curve fit Mag Magnitude of a set of vectors Orthogonalize Orthogonalize a matrix Product Computes product of the terms in a vector RowCompU Computes the upper row compression of a matrix. SXV Multiplies a scalar times a vector. Sep Separate a matrix or vector based on the criteria entered in s. Skew Converts a vector into a skew symmetric matrix. SkewSq Computes the product of two skew symmetric matrices derive from vectors. SkewSymm Converts a vector into a skew symmetric matrix SumC Always sums by column even if x is a single row. SumV Sum a set of vectors in a 3-by-n matrix Unit Unitize vectors by column.

### MathUtils

 DeltaEig Computes the delta eigenvalues for a given a small perturbation of a, e FTrunc Simulates floating point truncation to -. FindIfInBetween Determines if x is in between odd-even pairs. FloatToTwosComplement Converts a float to two's complement array. Odd 1 if the value is odd R2P5 Rounds towards zero to the nearest 1/2. Ramp Generate a ramp signal at t0 from value v0 to vF in time interval t Ramps Generates ramps for any number of inputs. Since version 10. RoundN Round to n decimal places TriangleWave Generates a triangle wave. 0 is the beginning and 2*pi is the end. TwosComplementToFloat Converts a two's complement array to float.

### Probability

 BinomialTheorem Computes the binomial theorem. CRand Covariance matrix transformation CableTensionExample Cable tension example. Combinations The number of combinations of r articles in n samples. ConfidenceInterval Computes the confidence interval. CovarianceRHS Generates the covariance derivative. EMarkov Find the correlation time and the mean squared value for a Markov sequence. ErrorCombination Combine errors given a function. GaussianCPDF Cumulative probability density function for a Gaussian GaussianPDF Compute the probability density function for a Gaussian distribution. GaussianRSG Gaussian Random Sequence Generator Using the Box-Mueller Transform Markov Generate random output from a Gauss-Markov process. NormalDistribution Matrix normal or Gaussian distribution. RMarkov Generates the autocorrelation function for a Markov Process. RandP Generate a Poission random matrix. RandPM Generates uniform random matrices between -1 and +1 RandPN Generate a Poission random matrix using a normal approximation. Random Compute a random nxm matrix SMarkov Generates the spectral function for a Markov Process. SignTest Compare the relative accuracy of two signals.

### Solvers

 BisectionZero Use bisection method to find the zero crossing of a function. LEPDS Solves the problem ax = b when a is positive definite symmetric LSSVD Solves ax = b using the singular value decomposition ModNewt Finds the solution to f(x) = 0 given derivative information. NLEqSolver Solves a set of equations for zero using Newton's method. NLEqSolverWrapper Wraps the Newton's method solver by trying several values. NewtRaph Newton Raphson root finding method Secant Finds the solution to f(x) = 0 without derivatives.