1.3basic calculations 5
Listing 1.3: Trigonometry
1 >> sin(2*pi)+exp(−3/2)
2 ans =
3 0.
The arguments to
trigonometric functions
should be given in
radians.
Comments:
- MATLABhas pre-defined constants e. g.πmay be typed aspi.
- You must explicitly type all arithmetic operations e. g.sin(2*pi)not
sin(2pi). - sin(x)andexp(x)correspond tosin(x)andexrespectively.
Listing 1.4: Complex numbers
1 >> 5+5j
2 ans =
3 5.0000 + 5.0000i
Comments:
- Complex numbers can be entered using the basic imaginary unitiorj.
Listing 1.5: More trigonometry
1 >> atan(5/5)
2 ans =
3 0.
5 >> 10*log10(0.5)
6 ans =
7 −3.
Comments:
- atan(x)andlog10(x)correspond totan−^1 (x)andlog 10 (x)respect-
ively.
Built-in functions
There are many other built-inMATLABfunctions for performing basic cal-
culations. These can be searched from the Help Browser which is opened by
clicking on its icon (like the icon used to indicate this Hints and Tips section)
in theMATLABdesktop toolbar.