

To divide 8 by the difference between 2 and 3, we type 8/(2-3)Īnd again get the right answer. As another example, if we want to divide 8 by 2 and then subtract 3, we type (8/2)-3Īnd get the right answer. If you don't put brackets, Matlab has its own built in order of operations: multiplication/division first, then addition/subtraction. Carefully note the placement of the brackets. If we want to multiply 5 by the sum of 2 and 3, we type 5*(2+3)Īnd this gives us the correct value.

For example, if you want to multiply 5 by 2 then add 3, we can type (5*2)+3Īnd we get the correct value.

This can be specified by the use of brackets. When working with arithmetic operations, it's important to be clear about the order in which they are to be carried out. The above are just a sample - MATLAB has lots of built-in functions. Log(x) base e logarithm of x (normally written ln) trigonometric, exponential): sin(x) sine of x (in radians) MATLAB has all of the basic arithmetic operations built in: + additionĪs well as many more complicated functions (e.g. "Scientific notation" is expressed with "10^" replaced by "e" - that is, 10^7 is written 1e7 and 2.15x10^-3 is written 2.15e-3. Type 3+2Ĭan also do more complicated operations, like taking exponents: for "3 squared" type 3^2 3^2įor "two to the fourth power" type 2^4 2^4 Arithmetic Operations and FunctionsĪt its simplest, we can use MATLAB as a calculator. Everything you need for EOS 225 should be included in the following tutorials. You can work through these at your leisure, if you want. Lots of MATLAB demos are available online at The following tutorials are intended to give you an introduction to scientific computing in MATLAB. MATLAB is a programming language that is very useful for numerical simulation and data analysis.
