Graphics Programs Reference
In-Depth Information
>> v = sin(10)
v=
-0.5440
>> uˆ2 + vˆ2
ans =
1
MATLAB uses double-precision floating point arithmetic, which is accurate
toapproximately15digits;however,MATLABdisplaysonly5digitsbydefault.
To display more digits, type format long . Then all subsequent numerical
output will have 15 digits displayed. Type format short to return to 5-digit
display.
MATLAB differs from a calculator in that it can do exact arithmetic. For
example,itcanaddthefractions1 / 2and1 / 3symbolicallytoobtainthecorrect
fraction 5 / 6. We discuss how to do this in the section Symbolic Expressions,
Variable Precision, and Exact Arithmetic on the next page.
Algebra
Using MATLAB's Symbolic MathToolbox, you can carry out algebraic
or symbolic calculations suchas factoring polynomials or solving algebraic
equations. Type help symbolic to make sure that the Symbolic Math Tool-
box is installed on your system.
To perform symbolic computations, you must use syms to declare the vari-
ables you plan to use to be symbolic variables. Consider the following series
of commands:
>> syms x y
>> (x - y)*(x - y)ˆ2
ans =
(x-y)^3
>> expand(ans)
Search WWH ::




Custom Search