034IN "Fundamentals of Automatic Control" - Introduction to MATLAB

Part 4 - Symbolic Math Computations

This is the fourth MATLAB live script of the collection 034IN "Fundamentals of Automatic Control" - Introduction to MATLAB, devoted to introduce the MATLAB environment and tools for solving practical problems related to the topics of the 034IN course, i.e. performance analysis of dynamic systems, design of control law for continuous-time linear dynamical systems, approximate discretization of a continuous-time control law etc.
Use this link to go back to the main live script of the collection.
Table of Contents

Introduction

Symbolic Math Toolbox provides functions for solving, representing and manipulating symbolic math equations. The toolbox offers functions for calculus, linear algebra, algebraic and differential equations, simplification and manipulation of equations. Symbolic Math Toolbox allows analytical derivations, integrations, simplifications, solving of equations, applying Laplace transform, and much more.

With a Little Help from the 'help' Command!

Here is a list of the main categories of topics, available with the help command, related to symbolic calculation
Symbolic Math Toolbox
help symbolic
Symbolic Math Toolbox Version 25.2 (R2025b) 28-Jul-2025 Symbolic Objects ---------------- Symbolic Variables & Expressions str2sym - Evaluate string representing symbolic expression sym - Create symbolic object. syms - Short-cut for constructing symbolic objects symvar - Short-cut for constructing symbolic objects symfun - Create symbolic functions sympref - Set symbolic preferences vpa - Variable-precision arithmetic Operators and Elementary Operations minus - - subtraction. plus - + addition. power - .^ array power. times - .* array multiplication. ldivide - \ left division. rdivide - / right division. mtimes - * matrix multiplication. mldivide - \ matrix left division. mrdivide - / matrix right division. mpower - ^ matrix power. transpose - .' matrix transpose. ctranspose - ' matrix complex conjugate transpose. uminus - - negation. eq - == Define equation logical - Check validity of equation or inequality Symbolic Functions & Tools argnames - Input variables of symbolic function children - Subexpressions or terms of symbolic expression displayFormula - Display a symbolic formula without evaluating it fold - Combine (fold) vector using function formula - Mathematical expression defining symbolic function has - Check if expression contains particular subexpression isfinite - Check whether symbolic array elements are finite isinf - Check whether symbolic array elements are infinite isnan - Check whether symbolic array elements are NaNs piecewise - Conditionally defined expression or function symfun - Create symbolic functions Conversion cell2sym - Convert cell array to symbolic array char - Convert sym object to string dec2bin - Convert decimal integer to its binary representation dec2hex - Convert decimal integer to its hexadecimal representation double - Convert symbolic values to MATLAB double precision int8 - Convert to signed 8-bit integers int16 - Convert to signed 16-bit integers int32 - Convert to signed 32-bit integers int64 - Convert to signed 64-bit integers poly2sym - Create symbolic polynomial from vector of coefficients single - Convert symbolic matrix to single precision string - Convert sym scalar or array to string. sym2cell - Convert symbolic array to cell array sym2poly - Extract vector of all numeric coefficients, including zeros, from symbolic polynomial symfun - Create symbolic functions uint8 - Convert to unsigned 8-bit integers uint16 - Convert to unsigned 16-bit integers uint32 - Convert to unsigned 32-bit integers uint64 - Convert to unsigned 64-bit integers vpa - Variable-precision arithmetic Units of Measurement -------------------- Define, Create, Convert Units checkUnits - Check for compatible dimensions and consistent units findUnits - Find units in input isUnit - Determine if input is a symbolic unit mixedUnits - Expand as linear combination of compatible units newUnit - Define new unit removeUnit - Remove unit separateUnits - Separate units from expression simplify - Algebraic simplification str2symunit - Convert character vector or string to unit symunit - Units of measurement symunit2str - Convert unit to character vector unitConversionFactor - Conversion factor between units unitConvert - Rewrite units in terms of other symbolic units unitInfo - Information on units of measurement Unit Systems baseUnits - Base units of unit system derivedUnits - Derived units of unit system newUnitSystem - Define unit system removeUnitSystem - Remove unit system unitSystems - List available unit systems Equation Solving ---------------- Linear and Nonlinear Equations and Systems equationsToMatrix - Convert set of linear equations to matrix form finverse - Functional inverse linsolve - Solve linear system of equations given in matrix form poles - Poles of expression or function solve - Equations and systems solver vpasolve - Numeric solver Ordinary Differential Equations (ODEs) dsolve - Differential equations and systems solver massMatrixForm - Extract mass matrix and right side of semilinear system of DAEs odeFunction - Convert symbolic expressions to function handle for ODE solvers odeToVectorField - Reduce order of differential equations to 1 Differential Algebraic Equations (DAEs) daeFunction - Convert system of differential algebraic equations to MATLAB function handle suitable for ode15i decic - Find consistent initial conditions for first-order implicit ODE system with algebraic constraints findDecoupledBlocks - Search for decoupled blocks in systems of equations incidenceMatrix - Find incidence matrix of system of equations isLowIndexDAE - Check if differential index of system of equations is lower than 2 massMatrixForm - Extract mass matrix and right side of semilinear system of differential algebraic equations odeFunction - Convert symbolic expressions to function handle for ODE solvers reduceDAEIndex - Convert system of first-order differential algebraic equations to equivalent system of differential index 1 reduceDAEToODE - Convert system of first-order semilinear differential algebraic equations to equivalent system of differential index 0 reduceDifferentialOrder - Reduce system of higher-order differential equations to equivalent system of first-order differential equations reduceRedundancies - Simplify system of first-order differential algebraic equations by eliminating redundant equations and variables Formula Manipulation and Simplification --------------------------------------- Simplification simplify - Algebraic simplification simplifyFraction - Symbolic simplification of fractions subexpr - Rewrite symbolic expression in terms of common subexpressions Rewriting Polynomials & Fractions coeffs - Coefficients of polynomial expand - Symbolic expansion of polynomials and elementary functions horner - Horner nested polynomial representation numden - Extract numerator and denominator partfrac - Partial fraction decomposition Rewriting & Decomposition of Expressions children - Subexpressions or terms of symbolic expression collect - Collect coefficients combine - Combine terms of identical algebraic structure compose - Functional composition divisors - Divisors of integer or expression factor - Factorization isolate - Isolate variable or expression in equation lhs - Left side (LHS) of equation rewrite - Rewrite expression in terms of another function rhs - Right side (RHS) of equation Substitution subexpr - Rewrite symbolic expression in terms of common subexpressions subs - Symbolic substitution Calculus -------- Differentiation diff - Differentiate symbolic expression or function functionalDerivative - Functional derivative Integration changeIntegrationVariable - Integration by variable substitution int - Definite and indefinite integrals integrateByParts - Integration by parts rsums - Interactive evaluation of Riemann sums vpaintegral - Numerical integration using variable precision Vector Analysis curl - Curl of vector field divergence - Divergence of vector field gradient - Gradient vector of scalar function hessian - Hessian matrix of scalar function jacobian - Jacobian matrix laplacian - Laplacian of scalar function potential - Potential of vector field vectorPotential - Vector potential of vector field Series Expansions pade - Pade approximant rsums - Interactive evaluation of Riemann sums series - Puiseux series taylor - Taylor series taylortool - Taylor series calculator Sums & Products cumprod - Symbolic cumulative product cumsum - Symbolic cumulative sum symprod - Product of series symsum - Sum of series Limits limit - Compute limit of symbolic expression Transforms fourier - Fourier transform htrans - Hilbert transform ifourier - Inverse Fourier transform ihtrans - Inverse Hilbert transform ilaplace - Inverse Laplace transform iztrans - Inverse Z-transform laplace - Laplace transform sympref - Set symbolic preferences ztrans - Z-transform Linear Algebra -------------- Matrix Operations cat - Concatenate symbolic arrays along specified dimension colon - Create symbolic vectors, array subscripting, and for-loop iterators horzcat - Concatenate symbolic arrays horizontally numel - Number of elements of symbolic array size - Symbolic matrix dimensions sort - Sort elements of symbolic vectors or matrices vertcat - Concatenate symbolic arrays vertically Matrix Transformations diag - Create or extract diagonals of symbolic matrices reshape - Reshape symbolic array tril - Return lower triangular part of symbolic matrix triu - Return upper triangular part of symbolic matrix Solving Linear Equations adjoint - Adjoint of symbolic square matrix cond - Condition number of matrix det - Compute determinant of symbolic matrix equationsToMatrix - Convert set of linear equations to matrix form inv - Compute symbolic matrix inverse linsolve - Solve linear system of equations given in matrix form norm - Norm of matrix or vector pinv - Moore-Penrose inverse (pseudoinverse) of symbolic matrix rank - Find rank of symbolic matrix rref - Reduced row echelon form of matrix (Gauss-Jordan elimination) Matrix Basis colspace - Column space of matrix null - Form basis for null space of matrix orth - Orthonormal basis for range of symbolic matrix Matrix Factorizations chol - Cholesky factorization lu - LU factorization qr - QR factorization svd - Singular value decomposition of symbolic matrix Eigenvalues and Eigenvectors charpoly - Characteristic polynomial of matrix eig - Eigenvalues and eigenvectors of symbolic matrix jordan - Jordan form of matrix Matrix Analysis & Vector Calculus curl - Curl of vector field divergence - Divergence of vector field gradient - Gradient vector of scalar function hessian - Hessian matrix of scalar function jacobian - Jacobian matrix laplacian - Laplacian of scalar function potential - Potential of vector field vectorPotential - Vector potential of vector field Matrix Normal Forms hermiteForm - Hermite form of matrix jordan - Jordan form of matrix smithForm - Smith form of matrix Special Matrices bernsteinMatrix - Bernstein matrix toeplitz - Symbolic Toeplitz matrix Matrix Functions expm - Matrix exponential funm - General matrix function logm - Matrix logarithm sqrtm - Matrix square root Assumptions ----------- Set Assumptions assume - Set assumption on symbolic object assumeAlso - Add assumption on symbolic object assumptions - Show assumptions affecting symbolic variable, expression, or function clear all - Remove items from MATLAB workspace and reset MuPAD engine in - Numeric type of symbolic input piecewise - Conditionally defined expression or function reset - Close MuPAD engine Check Conditions isAlways - Check whether equation or inequality holds for all values of its variables logical - Check validity of equation or inequality Polynomials ----------- Polynomial Operations coeffs - Coefficients of polynomial poly2sym - Create symbolic polynomial from vector of coefficients root - Represent roots of polynomial roots - Calculates roots from vector of polynomial coefficients sym2poly - Extract vector of all numeric coefficients, including zeros, from symbolic polynomial Characterize Matrices charpoly - Characteristic polynomial of matrix minpoly - Minimal polynomial of matrix Special Polynomials bernstein - Bernstein polynomials chebyshevT - Chebyshev polynomials of the first kind chebyshevU - Chebyshev polynomials of the second kind gegenbauerC - Gegenbauer polynomials hermiteH - Hermite polynomials jacobiP - Jacobi polynomials laguerreL - Generalized Laguerre Function and Laguerre Polynomials legendreP - Legendre polynomials Mathematical Functions ---------------------- Constants catalan - Catalan constant eulergamma - Euler-Mascheroni constant Logarithms, Polylogarithms, and Zeta Function hurwitzZeta - Hurwitz zeta function log - Natural logarithm of entries of symbolic matrix log10 - Logarithm base 10 of entries of symbolic matrix log2 - Logarithm base 2 of entries of symbolic matrix dilog - Dilogarithm function polylog - Polylogarithm psi - Digamma function zeta - Riemann zeta function Trigonometric Functions sin - Symbolic sine function sinc - Symbolic sinc function returns sin(pi*x)/(pi*x) sind - Symbolic sine function for argument in degrees cos - Symbolic cosine function cosd - Symbolic cosine function for argument in degrees tan - Symbolic tangent function tand - Symbolic tangent function for argument in degrees cot - Symbolic cotangent function cotd - Symbolic cotangent function for argument in degrees sec - Symbolic secant function secd - Symbolic secant function for argument in degrees csc - Symbolic cosecant function cscd - Symbolic cosecant function for argument in degrees asin - Symbolic inverse sine function asind - Symbolic inverse sine function for argument in degrees acos - Symbolic inverse cosine function acosd - Symbolic inverse cosine function for argument in degrees atan - Symbolic inverse tangent function atand - Symbolic inverse tangent function for argument in degrees acot - Symbolic inverse cotangent function acotd - Symbolic inverse cotangent function for argument in degrees asec - Symbolic inverse secant function asecd - Symbolic inverse secant function for argument in degrees acsc - Symbolic inverse cosecant function acscd - Symbolic inverse cosecant function for argument in degrees Trigonometry, Other deg2rad - Convert angle from degrees to radians rad2deg - Convert angle from radians to degrees hypot - Square root of sum of squares (hypotenuse) Hyperbolic Functions sinh - Symbolic hyperbolic sine function cosh - Symbolic hyperbolic cosine function tanh - Symbolic hyperbolic tangent function coth - Symbolic hyperbolic cotangent function sech - Symbolic hyperbolic secant function csch - Symbolic hyperbolic cosecant function asinh - Symbolic inverse hyperbolic sine function acosh - Symbolic inverse hyperbolic cosine function atanh - Symbolic inverse hyperbolic tangent function acoth - Symbolic inverse hyperbolic cotangent function asech - Symbolic inverse hyperbolic secant function acsch - Symbolic inverse hyperbolic cosecant function Complex Numbers abs - Absolute value of real or complex value angle - Symbolic polar angle atan2 - Symbolic four-quadrant inverse tangent atan2d - Symbolic four-quadrant inverse tangent for argument in degrees imag - Imaginary part of complex number real - Real part of complex number sign - Sign of real or complex value signIm - Sign of the imaginary part of complex number Gamma and Error Functions beta - Beta function factorial - Factorial function gamma - Gamma function gammaln - Logarithmic gamma function igamma - Incomplete gamma function nchoosek - Binomial coefficient pochhammer - Pochhammer symbol dawson - Dawson integral erf - Error function erfc - Complementary error function erfcinv - Inverse complementary error function erfi - Imaginary error function erfinv - Inverse error function fresnelc - Fresnel cosine integral function fresnels - Fresnel sine integral function Trigonometric, Elliptic, and Other Integrals coshint - Hyperbolic cosine integral function cosint - Cosine integral function ei - One-argument exponential integral function expint - Exponential integral function eulergamma - Euler-Mascheroni constant logint - Logarithmic integral function sinhint - Hyperbolic sine integral function sinint - Sine integral function ssinint - Shifted sine integral function ellipke - Complete elliptic integrals of the first and second kinds ellipticCE - Complementary complete elliptic integral of the second kind ellipticCK - Complementary complete elliptic integral of the first kind ellipticCPi - Complementary complete elliptic integral of the third kind ellipticE - Complete and incomplete elliptic integrals of the second kind ellipticF - Incomplete elliptic integral of the first kind ellipticK - Complete elliptic integral of the first kind ellipticNome - Elliptic nome function ellipticPi - Complete and incomplete elliptic integrals of the third kind Jacobi Elliptic Functions jacobiAM - Jacobi amplitude function jacobiCD - Jacobi CD elliptic function jacobiCN - Jacobi CN elliptic function jacobiCS - Jacobi CS elliptic function jacobiDC - Jacobi DC elliptic function jacobiDN - Jacobi DN elliptic function jacobiDS - Jacobi DS elliptic function jacobiNC - Jacobi NC elliptic function jacobiND - Jacobi ND elliptic function jacobiNS - Jacobi NS elliptic function jacobiSC - Jacobi SC elliptic function jacobiSD - Jacobi SD elliptic function jacobiSN - Jacobi SN elliptic function jacobiZeta - Jacobi zeta function Dirac, Heaviside and Related Functions dirac - Dirac delta function heaviside - Heaviside step function kroneckerDelta - Kronecker delta function rectangularPulse - Rectangular pulse function triangularPulse - Triangular pulse function Airy, Bessel, and Hankel Functions airy - Airy function besselh - Hankel function besseli - Modified Bessel function of the first kind besselj - Bessel function of the first kind besselk - Modified Bessel function of the second kind bessely - Bessel function of the second kind Hypergeometric, Kummer, and Whittaker Functions hypergeom - Hypergeometric function kummerU - Confluent hypergeometric Kummer U function meijerG - Meijer G-function whittakerM - Whittaker M function whittakerW - Whittaker W function Lambert W and Wright Functions lambertw - Lambert W function wrightOmega - Wright omega function Other Functions sqrt - square root nthroot - n-th root Numbers and Precision --------------------- digits - Change variable precision used double - Convert symbolic values to MATLAB double precision vpa - Variable-precision arithmetic ceil - Round symbolic matrix toward positive infinity conj - Symbolic complex conjugate fix - Round toward zero floor - Round symbolic matrix toward negative infinity frac - Symbolic matrix element-wise fractional parts imag - Imaginary part of complex number max - Largest elements min - Smallest elements real - Real part of complex number round - Symbolic matrix element-wise round Number Theory ------------- bernoulli - Bernoulli numbers and polynomials divisors - Divisors of integer or expression euler - Euler numbers and polynomials fibonacci - Fibonacci numbers gcd - Greatest common divisor harmonic - Harmonic function (harmonic number) lcm - Least common multiple mod - Symbolic modulus after division nextprime - Next prime number prevprime - Previous prime number quorem - Quotient and remainder rat - Rational approximation, continued fraction rem - Remainder after division factorIntegerPower - Write an integer as a power with maximal exponent nthprime - N-th prime number powermod - Modular power isprime - True for prime numbers Graphics -------- fcontour - Plot contours fimplicit - Plot implicit symbolic equation or function fimplicit3 - Plot 3-D implicit equation or function fmesh - Plot 3-D mesh fplot - Plot symbolic expression or function fplot3 - Plot 3-D parametric curve fsurf - Plot 3-D surface Code Generation --------------- matlabFunction - Convert symbolic expression to function handle or file matlabFunctionBlock - Convert symbolic expression to MATLAB Function block simscapeEquation - Convert symbolic expressions to Simscape language equations symReadSSCParameters - Load parameters from Simscape component symReadSSCVariables - Load variables from Simscape component symWriteSSC - Create new Simscape component ccode - C code representation of symbolic expression fortran - Fortran representation of symbolic expression latex - LaTeX form of symbolic expression mathml - MathML form of symbolic expression texlabel - TeX representation of symbolic expression Symbolic Math Toolbox Documentation

Before You Start

In this live script you will learn, by running some examples
clear
close all
clc % cleaning the workspace
sympref('default') % forcing the default preferences for the Symbolic Math Toolbox
ans = struct with fields:
FourierParameters: [1 -1] HeavisideAtOrigin: 1 AbbreviateOutput: 1 TypesetOutput: 1 FloatingPointOutput: 0 PolynomialDisplayStyle: 'default' MatrixWithSquareBrackets: 0
old_prefs = sympref(); % store the actual Symbolic Toolbox preferences
sympref('MatrixWithSquareBrackets',true); % matrix style using []
What are the symbolic Toolbox preferences? How to set it properly?
help sympref
sympref - Set symbolic settings This MATLAB function sets the symbolic setting pref to value and returns the previous value of the setting to oldVal. Syntax oldVal = sympref(pref,value) oldVal = sympref(pref) oldPrefs = sympref(prefs) oldPrefs = sympref() Input Arguments pref - Symbolic setting character vector | string value - Value of symbolic setting 'default' (default) | valid value prefs - Symbolic settings structure array Output Arguments oldVal - Value of symbolic setting valid value oldPrefs - All symbolic settings structure array Examples Change Parameter Values of Fourier Transform Change Value of Heaviside Function at Origin Modify Display of Symbolic Expressions in Live Scripts Display Symbolic Results in Floating-Point Format Modify Output Order of Symbolic Polynomial Modify Display of Symbolic Matrix in Live Scripts Save and Restore All Symbolic Settings See also fourier, heaviside, ifourier, digits, vpa, taylor, latex, mathml Introduced in Symbolic Math Toolbox in R2015a Documentation for sympref

Symbolic Scalar Variables & Functions

Symbolic Scalar Variables

The command
syms var1
allows the definition of a scalar symbolic variable, named var1, assigning to the new variable a symbolic value corresponding to the variable's name
A simple example:
syms x y t
disp(x)
x
disp(y)
y
Then, you may create a symbolic expression using the new variables, and assign the result to one of them
t = 2*y^2-sqrt(abs(x-pi))/sin(2*x-pi/6);
disp(t)

Assumptions on Symbolic Variables

It is possible to declare assumptions on symbolic variables, regarding particular features or data type of the variables. The assumption can be 'real', 'rational', 'integer', or 'positive'.
syms a b integer
syms c positive rational
syms d real
disp(assumptions([a,b,c,d]))
Alternatively, you may check assumptions on a single symbolic variable
syms a positive integer
disp(assumptions(a))

Symbolic Functions

You may create symbolic scalar functions with one or two arguments, simply by typing, for example
syms z(t) f(x, y)
Both z and fare abstract symbolic functions. You have to assign an expression to them before using them.

Example

syms f(x, y)
f(x, y) = 2*x+sqrt(3*y^2+4)
f(x, y) = 
Now, it is possible to evaluate the function at a specific input point:
f(1,2)
ans = 
6

Solving Symbolic Equations

Is it possible to solve linear or nonlinear equations using the Symbolic Toolbox? Yes, it is: you can exploit the MATLAB command solve.
help symbolic/solve
sym/solve - Equations and systems solver This MATLAB function solves the symbolic equation eqn for the variable var. Syntax S = solve(eqn,var) S = solve(eqn,var,Name=Value) Y = solve(eqns,vars) Y = solve(eqns,vars,Name=Value) [y1,...,yN] = solve(eqns,vars) [y1,...,yN] = solve(eqns,vars,Name=Value) [y1,...,yN,parameters,conditions] = solve(eqns,vars,ReturnConditions=true) Input Arguments eqn - Equation to solve symbolic expression | symbolic equation var - Variable to solve for symbolic variable | symbolic function eqns - System of equations to solve symbolic expressions | symbolic equations vars - Variables to solve for symbolic vector | symbolic matrix | comma-separated list Name-Value Arguments Real - Return only real solutions false (default) | true ReturnConditions - Return parameters and conditions false (default) | true IgnoreAnalyticConstraints - Simplification rules applied to expressions and equations false (default) | true IgnoreProperties - Option to return solutions inconsistent with properties of variables false (default) | true MaxDegree - Maximum degree of polynomial equations for which solver uses explicit formulas 2 (default) | positive integer smaller than 5 PrincipalValue - Option to return one solution false (default) | true Output Arguments S - Solutions of equation symbolic array Y - Solutions of system of equations structure y1,...,yN - Solutions of system of equations symbolic variables parameters - Parameters in solution vector of generated parameters conditions - Conditions under which solutions are valid vector of symbolic expressions Examples Solve Quadratic Equation Solve Polynomial and Return Real Solutions Numerically Solve Equations Solve Multivariate Equations and Assign Outputs to Structure Solve Inequalities Solve Multivariate Equations and Assign Outputs to Variables Use Parameters and Conditions to Refine Solution Apply Mathematical Rules Simplify Solutions Ignore Assumptions on Variables Solve Polynomial Equations of High Degree Return One Solution Different Solutions from Different Variable Orders Solve Equations for Symbolic Functions and Derivatives See also dsolve, isolate, linsolve, root, subs, symvar, vpasolve, Solve Symbolic Equation Introduced in Symbolic Math Toolbox before R2006a Documentation for sym/solve Other uses of sym/solve

How to Define a Symbolic Equation: A Few Examples

Given the equations
let's use the command solve to determine each solution, if possible.

First Example

Let's define the symbolic variable x and the parameters
syms x
syms a b c
Define the equation as symbolic expression - note the particular sintax
Eq1 = a*x^4+b*x^2+c == 0
Eq1 = 
Let's solve the equation, declaring explicitly that x si the variable, whereas and c are the coefficients of the equation:
S1 = solve(Eq1, x)
S1 = 

Second Example

Let's define the symbolic variable x
clear a b c x
syms x
Define the equation as symbolic expression
Eq2 = (x/2)+(1/x) == x
Eq2 = 
Let's solve the equation
S2 = solve(Eq2)
S2 = 

Third Example

clear x
 
syms x y
Define the equation as a set of two symbolic expression (i..e. a column-vector, containing two equations)
Eq3 = [ 2*x+y ==0;
x-y == 1 ]
Eq3 = 
Let's solve the equations
S3 = solve(Eq3)
S3 = struct with fields:
x: 1/3 y: -2/3
If the solve function returns an empty object, then no solutions exist:
Eq3b = [ 3*x+2 == 0;
3*x-1 == 0]
Eq3b = 
solve(Eq3b)
ans = Empty sym: 0-by-1

Fourth Example: Numerically Solve Equations

When the solve function cannot symbolically solve an equation, it tries to find a numeric solution using the vpasolve function.
Note: The vpasolve function returns the first solution found.
clear x y
syms x
Eq4 = x == cos(x)
Eq4 = 
 
S4 = solve(Eq4)
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
S4 = 
0.73908513321516064165531208767387

The Laplace Transform

Why use transforms?
A simple example:
syms t s % t and s are now symbolic variables
f = exp(-t) * cos(2 * t)
F = laplace(f, t, s)
You can also calculate the inverse Laplace transform:
ft1 = ilaplace(F, s, t)
For Laplace transform properties and how to use the Symbolic Math Toolbox to compute a Laplace transform or an inverse transform, refer to the live script Intro_MATLAB_034IN_FAC_p4L_1_LAPLACE.mlx .
For application examples of the Laplace transform and how to use it in solving exercises in the 034IN course, refer to the live script Intro_MATLAB_034IN_FAC_p4L_2_LAPLACE_APPLIC.mlx .

Symbolic Vectors & Matrices

The two most effective ways (during this course) to define a symbolic vector or a symbolic matrix are as follows:

Examples: Using Already Existent Symbolic Variables

clear variables % let's delete all the variables defined so far
 
syms a b c % let's define some scalar symbolic variables
 
A = [a b c; c a b; b c a]
Note: the sum of the elements over each row and each column is the same
sum(A(:,1))
 
sum(A(2,:))
Another example:
syms m1 m2 k1 k2 omega
 
M = [(-m1*omega^2 + k1) (-k1); (-k1) (-m2*omega^2 + k1 + k2)]
Let's evaluate the determinant of the M matrix, as an ordered polynomial of the symbolic variable ω:
detM = collect(det(M), omega)
We can also determine the symbolic values of ω that are the root of the polynomial:
omegaSOL = solve(detM, omega)

Examples: Creating Matrix of Symbolic Numbers

A particularly effective use of the command sym is to convert a matrix from numeric to symbolic form.
For example, given the numeric matrix defined as
A = [1 1 0; 0 1 0; 0 0 1] % a numeric matrix
we can obtain a symbolic representation of the same matrix simply by applying the command sym
Asym = sym(A)
or equivalently
Asym2 = sym([1 1 0; 0 1 0; 0 0 1])
For the complete syntax of the command sym, and some examples, refer to
help sym
or
doc sym

Linear Algebra with Symbolic Matrices

The answers to these questions and some useful examples are available in the live script Part 4A-2 - Application: Solving Linear Algebra Equations.

Summary

Using this live script you have:

Back to the Index

Use this link to go back to the main live script of the collection.

Back to the Previous Part: Vectors and Matrices

Use this link to go back to the previous live script of this collection.

Go to the Next Part: Visualization and Programming

Use this link to go to the next live script of the collection.