MATLAB as a calculator. MATLAB, at the lowest possible level, can be used as a calculator. The symbols for the four operations are the ones one writes on paper except for multiplication, whose symbol is *. Be careful: writing 3a for \(3\times a\) amounts to a syntax error, you must rather use 3*a. The name for the square root operator is sqrt.
Priorities. The priority among the four operations is the same as in any calculator: first the multiplications/divisions, then sums/differences. When one wants to enforce a different order of operations, parentheses must be used.
The = symbol. Notice that the symbol = is used for assignments rather than for comparing quantities: the instruction a=2 assigns the value 2 to the variable named a.
Printing. Every time that some value is assigned or some expression is evaluated, MATLAB prints that value unless a symbol ; (semicolon) is put at the end of the line. Together with the value is also printed the name of the variable. If you want to print just the value use the command disp. By default MATLAB prints only 6 digits of a number. After entering the command format long, the number of printed digits goes up to 16. When one wants to rather display a specific number of digits after the dot, say 23, of a variable or some calculation, say the variable a, then the instruction to use is the following: fprintf("a = %.23f",a) IMPORTANT: Octave also accepts using printf("a = %.23f",a), as shown in the code below.