15.7 Symbolic Mathematics with MATLAB 493
TABLE 15.14 Examples of MATLAB’s Symbolic Operations
Function Description of the Function Example Result of the Example
sym It creates a symbolic F1x sym('x^25*x6') F1x x^25*x 6
function. F2x sym('x3') F2x x 3
F3x sym('(x5)^2') F3x (x5)^2
F4x sym('5*xy2*xy') F4x 5*xy2*xy
factor When possible, it factorizes factor(Fx1) (x2)*(x3)
the function into simpler terms.
simplify It simplifies the function. simplify(F1x / F2x) x 2
expand It expands the function. expand(F3x) x^210*x 25
collect It simplifies a symbolic expression collect(F4x) 7*x2*y
by collecting like coefficients.
solve It solves the expression for its roots. solve(F1x) x 2 and x 3
ezplot(f, It plots the function f in the ezplot(F1x,0,5) See Figure 15.28
min, max) range of min and max.
Upon execution of the polyfitcommand, MATLAB will return the following coefficients,
c 0 1,c 1 3, andc 2 2, which leads to the equationyx
2
3 x2.
15.7 Symbolic Mathematics with MATLAB
In the previous sections, we discussed how to use MATLAB to solve engineering problems with
numerical values. In this section, we briefly explain the symbolic capabilities of MATLAB. In
symbolic mathematics, as the name implies, the problem and the solution are presented using
symbols, such asxinstead of numerical values. We will demonstrate MATLAB’s symbolic
capabilities using Examples 15.7 and 15.8.
Example 15.7 We will use the following functions to perform MATLAB’s symbolic operations, as shown in
Table 15.14.
f 41 x 2 5 xy 2 xy
f 31 x 2 1 x 52
2
f 21 x 2 x 3
f 11 x 2 x
2
5 x 6
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
圀圀圀⸀夀䄀娀䐀䄀一倀刀䔀匀匀⸀䌀伀䴀圀圀圀⸀夀䄀娀䐀䄀一倀刀䔀匀匀⸀䌀伀䴀