Upload
macey-sorrels
View
220
Download
0
Tags:
Embed Size (px)
Citation preview
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt1
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Bruce Mayer, PELicensed Electrical & Mechanical Engineer
Engr/Math/Physics 25
Chp11:
MuPAD
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt2
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Learning Goals
Understand and Open MuPAD “NoteBooks”
Work within the NoteBooks to perform SYMBOLIC CALCULATIONS including• Algebra• Transcendental Equations• Calculus• Ordinary
Differential Equations
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt3
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Chapter Sections NOT Covered
§4 → Matrix Operations §7 → LaPlace Transforms §8 → Special Functions
Carefully Study the Book for Syntax• Learn MuPAD by
– “Stare & Compare” (examples)– Hacking– And, if all else fails, then HELP!
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt4
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Learning Goals
Use MuPAD to create PLOTS of functions
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt5
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
MATLAB Symbolic MATH
In Addition to Using NUMBERS MATLAB can Manipulate SYMBOLS
Basically, a Mathematics HandBook has been codifed in Software by a group at the University of Paderborn in Germany
The MathWORKS Purchased The “MuPAD” Symbolic Math “Engine” (or “Kernal”), and Integrated it into MATLAB• MuPAD uses Pascal-like Syntax
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt6
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
MuPAD → SYMBOLIC Calcs
MuPAD, sort of Like SimuLink, is a program within-a Program• SimuLink creates Icon-based “Models” (.mdl)
of Mathematical Systems– SimuLink produces NUMERICAL Resuls
MuPAD creates “NoteBooks” (.mn) in which SYMBOLIC quantities can be used• The Symbols can be associated with NO
particular number value– It’s similar to a Math Book that does the work
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt7
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Symbolic Computation The Differences Between Symbolic and
Numeric Computation
Numerical SymbolicVariables Represent
NumbersVariables are Symbols; e.g., x, y, z, β, θ, σ
Answers can Only be Numbers
Answers can contain Variables and Functions
Numeric Computation can be done using
Standard Programming Languages
Symbolic computations are not similar to standard programming languages – they use symbolic Manipulations
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt8
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
MuPAD BackGround
MuPAD is a part a generic class of Software called a “Computer Algebra System” (CAS). • MuPAD research group at the University of
Paderborn, Germany originally developed this symbolic-manipulation software
The MathWORKS purchased MuPAD to replace the previous “Symbolic Math Kernal” written by MapleSoft
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt9
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Sample of MuPAD Capabilities
Create SYMBOLIC expressions and manipulate them algebraically.
Obtain SYMBOLIC and numeric solutions to algebraic and transcendental equations.
Perform SYMBOLIC LINEAR ALGEBRA operations, including obtaining expressions for determinants, matrix inverses, and others.
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt10
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Sample of MuPAD Capabilities
Perform SYMBOLIC differentiation and integration
Evaluate limits and series SYMBOLICALLY.
Obtain SYMBOLIC solutions to Ordinary Differential Equations (ODEs).
Solve ORDINARY DIFFERENTIAL EQUATIONS in terms of special functions or series.
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt11
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
MuPAD “NoteBook”
MuPAD creates within MATLAB its own working SubWindows Called NoteBooks• The User works/types in the “NoteBooks”• NoteBooks saved with extension: .mn
For MuPAD beginers it’s best start at the MuPAD “Welcome” screen
At the MATLAB Command Prompt type mupadwelcome
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt12
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
mupadwelcome Screen
Suggest Spending Some time in the “Getting Started” section
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt13
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Go Directly to WorkBook In MATLAB
command window type mupad
A MuPAD NoteBook
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt14
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
NoteBook Regions Calcs
CALC Regions
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt15
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
NoteBook Regions Text
TEXT Regions
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt16
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
NoteBook Regions OutPut
OutPut Regions
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt17
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Importance of “Evaluation”
The CALCULATION regions in MuPAD can be Inserted, Deleted, Edited
After Editing, We may have to EVALUATE the edit using the TOOL or PULL DOWN MENU
If a change in an OUTPUT Region does NOT happen as expected; then be SURE to EVALUATE the CALC region• “EVALUATE ALL” often works best
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt18
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Evaluate by TOOL Place the cursor
IN the CALC Region
Then Hit the Evaluate Button to initiate the Calculation
Note also the ASSIGNMENT Operator →
After EVALUATE:=
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt19
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Evaluate Options Use the Pull-
Down Menu for Different forms of the EVALUATION
Use the NOTEBOOK Pull-Down • “Evalute All”
works well
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt20
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
MuPAD Syntax & Structure TEXT regions do
NOT have a left Bracket
CALC & OUTPUT Regions DO have a Left Bracket
Interaction with INTEGERS Produces a SYMBOLIC OutPut
Using a decimal Point Produces a NUMBER Result
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt21
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
MuPAD Syntax & Structure Reserved Symbols
The Logarithms
Log Examples
I1
E
PI
ji
e
log e-Baseln
log b-Baselog
b
A Decimal
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt22
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
FLOAT command The float
command produces a DECIMAL Result for an otherwise integer display
Caveat on float(%) The float(%)
command changes the LAST EVALUATED result to a decimal; not necessarily the value right above (or below) the float(%) command
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt23
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Float(%) Confusion Bottom Expression
Evaluated LAST First Expression
Edited then Eval’d
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt24
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Command Bar ShortCuts to
Commands in:
The General Math MenuExpand SimplifyFactor CombineNormalize RewriteEvaluate Solve
Items on the Command barDerivatives Limits SumsIntegrals Rewrite Expressions ProductsSolve Equations Simplify Evaluate with x = aNumerical Evaluation and Rounding Equality Tests AssignmentMath Operators Factorials Function DefinitionTrig Functions Exponentials and Logs Piecewise DefinitionsReserved Symbols Greek Letters Physical UnitsMatrices and Vectors 2D Plot 3D Plot
Items on the Command Bar use# as a PlaceHolder that MUST be replaced
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt25
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Expression vs. Function An EXPRESSION
Example A MuPAD Function is
called a Procedure• Construction looks like
an anonymous fcn– Use “->” in place of @
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt26
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Plots are Easy Plot from a
Procedure (UDF) Plot from an
Expression
No SemiColon
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt27
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Printing from MuPAD Each NoteBook must
be Printed Separately Use standard Windows
Pull-Down Menu:• File → Print
These should appear in all Notebks• Student Name• ENGR25• HW Problem Number• Date Created/Printed
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt28
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Copy-n-Paste in MuPAD
The TEXT regions can be copied & pasted in the normal fashion
In MSWord The BLUE “Hand Math” must be copied and “Pasted Special” as a “Device Independent Bitmap”
In PPT A Plain “Bitmap” Paste-Special also works
Examples of the two Bitmaps into PPT shown below
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt29
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Copy-n-Paste in MuPAD
Pasting in MSWord requires TWO Copy-n-Paste Operations1. Paste TEXT Regions NORMALLY
2. Paste “Script Math” Using “Paste Special”
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt30
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Copy-n-Paste in MuPAD Copying GRAPHS
requires at THIRD Operation
Make the Graph
Click the Graph to Activate the Plot Menu Bar
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt31
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Copy-n-Paste in MuPAD Use Pull-Down
Menu The Thick border
indicates graphic has been copied to the clipboard
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt32
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Copy-n-Paste in MuPAD
Then NORMAL Paste into Word
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt33
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Copy-n-Paste in MuPAD
To AVOID All this Copy-n-Paste Hassle• Simplest is to just PRINT the MuPAD
NoteBook– Only get one Problem per sheet
• Do an alt+PrtScrn to copy the MuPAD window, then paste the whole window into MSWord
• Do an entire SCREEN-SHOT and crop it back to the MuPAD part– If MuPAD window not maximized
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt34
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt35
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Example Algebra
Given Expressions
For This situation find• The Product A∙B in Simplest Form• The Quotient A/B in Simplest Form• Evaluate A+B at y = 8.3 in
– Symbolic form– Numeric form
yyByyyA 2057515 223
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt36
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Alg
ebra E
xamp
le
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt37
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Solving Equation solve(eqn)
SOLVE in here
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt38
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Solve Systems of Eqns Solve by MuPAD
and
Note the use of SQUARE Brackets
35121
214311
111211
zyx
zyx
zyx
364
202
117342
zyx
zyx
zyx
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt39
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
solve::numeric Some eqns do NOT
have Algebraic solution, such as
Solve by regular MATLAB → fzero
Use fplot for
xx cos7142
0cos7142 xx
-5 -4 -3 -2 -1 0 1 2 3 4 5-25
-20
-15
-10
-5
0
5
10
X: -2.76Y: 0.1141
X: 2.76Y: 0.1141
Solutions ≈ x = ±2.76
ParabCos = @(x) x.^2-14 - 7*cos(x);fplot(ParabCos,[-5 5]), gridsL = fzero(ParabCos, -3)sR = fzero(ParabCos, +3)
RESULT:sL = -2.7460sR = 2.7460
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt40
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
solve::numeric Chk with MuPAD
Now use numeric modifier in MuPAD
No Symbol Soln
Only ONE Solution
LEFT Solution
RIGHT Solution
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt41
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Formatting Plots Make a plot, then
click the plot to CHANGE the tool Bar
Click the “Object Browser” Button
Explore the options in the two boxes at right (click upper item first)
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt42
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
After some menu Exploration
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt43
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
EXPORT Graphs
RIGHT Click the Graphic, then Follow the “Wizard” instructions
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt44
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Graph Export (JPEG) Result
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt45
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Derivatives diff(f,x)
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt46
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Example diff at a value A chance to use the subs command
Given:
Find by MuPAD
)3sinh(5cosh vvu
3.0vdv
du
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt47
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Integrals int(f,x)
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt48
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
ODEs solve(ode(#, #(#)))
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt49
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Example assume Solve this ODE
With Boundary Conditions
With Constraint
The assume command notifies MuPAD about the Constraint
02
2
kydx
yd
010 0 xdxdyy
0k
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt50
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
All Done for Today
MuPADused tobe Free
A 523 Page MuPAD Tutorialhttp://www.calvin.edu/~tmk5/research/mupad_tutorial.pdf
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt51
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Bruce Mayer, PELicensed Electrical & Mechanical Engineer
Engr/Math/Physics 25
Appendix
6972 23 xxxxf
tfyyy
735
[email protected] • ENGR-25_Lec-25_SimuLink-2.ppt52
Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods
Tutorial on Plot Formating Use
ENGR25_MuPAD_tutorial_format_plot_1111.mn
Solve Make Graph Format with
OBJECT BROWSER tool