Matlab Symbolic Math Toolbox User’s Guide
Matlab Symbolic Math Toolbox User’s Guide
MathWorks
Getting Started
Symbolic Math Toolbox Product Description . 1-2
Create Symbolic Numbers, Variables, and Expressions . 1-3
Create Symbolic Numbers 1-3
Create Symbolic Variables 1-3
Create Symbolic Expressions 1-5
Reuse Names of Symbolic Objects 1-5
Create Symbolic Functions 1-7
Create Symbolic Matrices . 1-9
Use Existing Symbolic Variables 1-9
Generate Elements While Creating a Matrix . 1-9
Create Matrix of Symbolic Numbers 1-10
Create Symbolic Matrix Variables . 1-11
Symbolic Objects to Represent Mathematical Objects . 1-17
Symbolic Number 1-17
Symbolic Scalar Variable, Function, and Expression 1-18
Symbolic Equation . 1-18
Symbolic Vector and Matrix 1-19
Symbolic Matrix Variable 1-20
Symbolic Matrix Function 1-21
Comparison of Symbolic Objects . 1-22
Perform Symbolic Computations 1-25
Differentiate Symbolic Expressions . 1-25
Integrate Symbolic Expressions . 1-26
Solve Equations . 1-27
Simplify Symbolic Expressions 1-29
Substitutions in Symbolic Expressions 1-30
Plot Symbolic Functions . 1-32
Use Assumptions on Symbolic Variables 1-38
Default Assumption 1-38
Set Assumptions . 1-38
Check Existing Assumptions 1-39
Delete Symbolic Objects and Their Assumptions . 1-39
Computational Mathematics in Symbolic Math Toolbox . 1-41
Next Step Suggestions for Symbolic Workflows in Live Editor 1-54
v
ContentsSymbolic Computations in MATLAB
2
Find Symbolic Variables in Expressions, Functions, Matrices 2-2
Find a Default Symbolic Variable . 2-2
Choose syms or sym Function 2-4
Change Output Display Format of Symbolic Results in the Live Editor 2-7
Add Subscripts, Superscripts, and Accents to Symbolic Variables in the
Live Editor 2-10
Copy and Paste Symbolic Output in Live Editor 2-14
Numeric to Symbolic Conversion 2-18
Conversion to Rational Symbolic Form 2-19
Conversion by Using Floating-Point Expansion 2-19
Conversion to Rational Symbolic Form with Error Term . 2-19
Conversion to Decimal Form 2-20
Choose Numeric or Symbolic Arithmetic . 2-21
Double-Precision Arithmetic 2-21
Variable-Precision Arithmetic . 2-21
Symbolic Arithmetic 2-22
Comparisons of Numeric and Symbolic Arithmetic . 2-23
Increase Precision of Numeric Calculations . 2-25
Compute Binomial Coefficients Exactly . 2-27
Numerical Computations with High Precision . 2-30
Decimal Digits of PI 2-33
Units of Measurement Tutorial . 2-35
Define and Convert Units 2-35
Use Temperature Units in Absolute or Difference Forms . 2-36
Verify Dimensions 2-36
Use Units in Differential Equations . 2-38
Unit Conversions and Unit Systems 2-41
Convert Units . 2-41
Temperature Unit Conversion . 2-42
Convert to SI, CGS, or US Unit Systems . 2-42
Define Custom Unit System from Existing System 2-44
Define Custom Unit System Directly 2-45
Unit System Definition 2-46
Units and Unit Systems List 2-48
Units List 2-48
SI Unit Prefixes List 2-58
Unit Systems List 2-59
Defining Constants of SI Units 2-60
vi ContentsUnits in Physics Calculations . 2-62
The Physics of the Damped Harmonic Oscillator . 2-66
Evaluating the Average Power Delivered by a Wind Turbine 2-76
Developing an Algorithm for Undistorting an Image 2-81
Electric Dipole Moment and Radiation Power . 2-87
Validate Simulink Model Using Symbolic Math Toolbox . 2-90
Mathematics
3
Solve Algebraic Equation . 3-3
Solve an Equation . 3-3
Return the Full Solution to an Equation 3-3
Work with the Full Solution, Parameters, and Conditions Returned by solve
3-4
Visualize and Plot Solutions Returned by solve . 3-5
Simplify Complicated Results and Improve Performance 3-6
Solve System of Algebraic Equations 3-7
Troubleshoot Equation Solutions from solve Function 3-17
Return Only Real Solutions . 3-17
Apply Simplification Rules . 3-17
Use Assumptions to Narrow Results 3-18
Simplify Solutions 3-19
Tips 3-19
Solve Equations Numerically . 3-21
Solve System of Linear Equations . 3-30
Solve System of Linear Equations Using linsolve . 3-30
Solve System of Linear Equations Using solve 3-31
Select Numeric or Symbolic Solver 3-33
Solve Parametric Equations in ReturnConditions Mode . 3-34
Solve Algebraic Equation Using Live Editor Task . 3-36
Solve Differential Equation . 3-43
First-Order Linear ODE . 3-43
Solve Differential Equation with Condition . 3-43
Nonlinear Differential Equation with Initial Condition . 3-44
Second-Order ODE with Initial Conditions . 3-44
Third-Order ODE with Initial Conditions . 3-44
More ODE Examples 3-45
viiSolve a System of Differential Equations 3-47
Solve a Second-Order Differential Equation Numerically 3-52
Solving Partial Differential Equations 3-54
Solve Differential Algebraic Equations (DAEs) . 3-61
Solve Semilinear DAE System . 3-70
Solve DAEs Using Mass Matrix Solvers . 3-77
Step 1. Convert DAEs to Function Handles . 3-77
Step 2. Find Initial Conditions 3-78
Step 3. Solve DAE System . 3-79
Analyze and Manipulate Differential Algebraic Equations . 3-82
Derive and Apply Inverse Kinematics to Two-Link Robot Arm 3-89
Gauss-Laguerre Quadrature Evaluation Points and Weights 3-96
Simulate a Stochastic Process by Feynman-Kac Formula . 3-106
The Black–Scholes Formula for Call Option Price . 3-114
Choose Function to Rearrange Expression . 3-119
Combine Terms of Same Algebraic Structures . 3-119
Expand Expressions . 3-120
Factor Expressions 3-121
Extract Subexpressions from Expression . 3-123
Collect Terms with Same Powers . 3-123
Rewrite Expressions in Terms of Other Functions . 3-124
Compute Partial Fraction Decompositions of Expressions . 3-125
Compute Normal Forms of Rational Expressions 3-125
Represent Polynomials Using Horner Nested Forms . 3-126
Extract Numerators and Denominators of Rational Expressions . 3-127
Simplify Symbolic Expressions . 3-129
Simplify Using Options . 3-130
Simplify Using Assumptions . 3-132
Simplify Fractions 3-132
Simplify Symbolic Expressions Using Live Editor Task . 3-134
Substitute Variables in Symbolic Expressions 3-140
Substitute Elements in Symbolic Matrices . 3-142
Substitute Scalars with Matrices . 3-144
Evaluate Symbolic Expressions Using subs . 3-146
Abbreviate Common Terms in Long Expressions 3-147
viii ContentsHarmonic Analysis of Transfer Function Output 3-150
Explore Single-Period Asset Arbitrage 3-156
Analytical Solutions of the Inverse Kinematics of a Humanoid Robot 3-160
Differentiation 3-171
Derivatives of Expressions with Several Variables . 3-172
More Examples 3-173
Integration . 3-176
Integration with Real Parameters . 3-178
Integration with Complex Parameters 3-179
High-Precision Numerical Integration Using Variable-Precision Arithmetic
3-180
Taylor Series . 3-182
Fourier and Inverse Fourier Transforms . 3-184
Fourier Transform Definition 3-184
Concept: Using Symbolic Workflows . 3-184
Calculate Beam Deflection Using Fourier Transform . 3-184
Solve Differential Equations Using Laplace Transform . 3-188
Solve Difference Equations Using Z-Transform 3-195
Definition: Z-transform . 3-195
Concept: Using Symbolic Workflows . 3-195
Workflow: Solve “Rabbit Growth” Problem Using Z-Transform . 3-195
References 3-199
Symbolic Summation 3-200
Comparing symsum and sum 3-200
Computational Speed of symsum versus sum 3-200
Output Format Differences Between symsum and sum . 3-201
Padé Approximant . 3-202
Limits . 3-209
One-Sided Limits . 3-209
Find Asymptotes, Critical, and Inflection Points 3-212
Functional Derivatives Tutorial 3-217
Learn Calculus in the Live Editor . 3-222
Differentiation 3-227
Integration . 3-235
Interactive Calculus in Live Editor . 3-239
Maxima, Minima, and Inflection Points 3-241
ixFind Extremum of Multivariate Function and Its Approximation . 3-249
Padé Approximant of Time-Delay Input 3-253
Solve Partial Differential Equation of Nonlinear Heat Transfer 3-259
Symbolic Matrix Computation . 3-265
Linear Algebraic Operations . 3-272
Symbolic Hilbert Matrix 3-272
Symbolic Linear Algebra Operations . 3-272
Variable-Precision Arithmetic 3-273
Symbolic Investigation of Singular Value . 3-274
Basic Algebraic Operations . 3-276
Singular Value Decomposition . 3-278
Eigenvalues 3-280
Jordan Canonical Form . 3-284
Eigenvalues of the Laplace Operator 3-286
Hilbert Matrices and Their Inverses 3-296
Markov Chain Analysis and Stationary Distribution . 3-300
Matrix Rotations and Transformations 3-305
Clear Assumptions and Reset the Symbolic Engine 3-312
Check Assumptions Set on Variables . 3-313
Effects of Assumptions on Computations 3-314
Recognize and Avoid Round-Off Errors 3-315
Use Symbolic Computations When Possible . 3-315
Perform Calculations with Increased Precision . 3-315
Compare Symbolic and Numeric Results 3-317
Plot the Function or Expression 3-317
Increase Speed by Reducing Precision 3-319
Prime Factorizations . 3-321
Handling Large Integers to Solve the 196 Problem 3-324
Graphics
4
Create Plots 4-2
Plot with Symbolic Plotting Functions 4-2
x ContentsPlot Functions Numerically 4-4
Plot Multiple Symbolic Functions in One Graph 4-5
Plot Multiple Symbolic Functions in One Figure 4-6
Combine Symbolic Function Plots and Numeric Data Plots 4-7
Combine Numeric and Symbolic Plots in 3-D . 4-9
Transform Spherical Coordinates to Cartesian Coordinates and Plot
Analytically 4-12
Tangent Plane and Normal Line of Implicit Surface 4-19
Analytical Plotting with Symbolic Math Toolbox . 4-23
Simulate the Motion of the Periodic Swing of a Pendulum . 4-40
Animation and Solution of Double Pendulum Motion . 4-55
Animation and Model of Automotive Piston . 4-62
Code Generation
5
Generate C or Fortran Code from Symbolic Expressions 5-2
Generate MATLAB Functions from Symbolic Expressions . 5-3
Generating a Function Handle . 5-3
Control the Order of Variables . 5-3
Generate a File . 5-4
Name Output Variables . 5-5
Generate MATLAB Function Blocks from Symbolic Expressions . 5-6
Generate and Edit a Block 5-6
Control the Order of Input Ports 5-6
Name the Output Ports . 5-6
Generate Simscape Equations from Symbolic Expressions 5-8
Convert Algebraic and Differential Equations 5-8
Limitations 5-9
Deploy Generated MATLAB Functions from Symbolic Expressions with
MATLAB Compiler 5-10
Generate C Code from Symbolic Expressions Using the MATLAB Coder
App 5-16
Using Symbolic Mathematics with Optimization Toolbox Solvers 5-30
Improving Accuracy and Performance in Optimization 5-39
Analytical Model of Cantilever Truss Structure for Simscape . 5-45
xiCustomize and Extend Simscape Libraries for a Custom DC Motor 5-53
Estimate Model Parameters of a Symbolically Derived Plant Model in
Simulink 5-62
MuPAD to MATLAB Migration
6
MuPAD Engines and MATLAB Workspace 6-2
Convert MuPAD Notebooks to MATLAB Live Scripts . 6-3
Convert a MuPAD Notebook .mn to a MATLAB Live Script .mlx . 6-3
Convert MuPAD Graphics to MATLAB Graphics 6-3
Known Issues 6-4
Troubleshoot MuPAD to MATLAB Translation Errors . 6-8
Troubleshoot MuPAD to MATLAB Translation Warnings . 6-15
Differences Between MATLAB and MuPAD Syntax 6-20
Call Built-In MuPAD Functions from MATLAB . 6-22
evalin . 6-22
feval 6-22
evalin vs. feval 6-23
Floating-Point Arguments of evalin and feval . 6-23
Functions
كلمة سر فك الضغط : books-world.net
The Unzip Password : books-world.net
تعليقات