<< Chapter < Page | Chapter >> Page > |
Learning a new skill, especially a computer program in this case, can be overwhelming. However, if we build on what we already know, the process can be handled rather effectively. In the preceding chapter we learned about MATLAB Graphical User Interface (GUI) and how to get help. Knowing the GUI, we will use basic math skills in MATLAB to solve linear equations and find roots of polynomials in this chapter.
The evaluation of expressions is accomplished with arithmetic operators as we use them in scientific calculators. Note the addtional operators shown in the table below:
Operator | Name | Description |
---|---|---|
+ | Plus | Addition |
- | Minus | Subtraction |
* | Asterisk | Multiplication |
/ | Forward Slash | Division |
\ | Back Slash | Left Matrix Division |
^ | Caret | Power |
.* | Dot Asterisk | Array multiplication (element-wise) |
./ | Dot Slash | Right array divide (element-wise) |
.\ | Dot Back Slash | Left array divide (element-wise) |
.^ | Dot Caret | Array power (element-wise) |
The following figure illustrates a typical calculation in the Command Window.
MATLAB allows us to build mathematical expressions with any combination of arithmetic operators. The order of operations are set by precedence levels in which MATLAB evaluates an expression from left to right. The precedence rules for MATLAB operators are shown in the list below from the highest precedence level to the lowest.
MATLAB has all of the usual mathematical functions found on a scientific calculator including square root, logarithm, and sine.
pi
returns the number 3.1416. To find the sine of pi, type in
sin(pi)
and press enter.sin(90*pi/180)
.log
returns the natural logarithm of the value. To find the ln of 10, type in log(10) and press enter, (ans = 2.3026).Notification Switch
Would you like to follow the 'A brief introduction to engineering computation with matlab' conversation and receive update notifications?