MATLAB allows step-by-step (interactive) working as well as writing and
executing scripts.
In the interactive mode, commands are written in the command window, or (in some
cases alternatively) executed from menu bars.
The active command line begins with the >> prompt. Here, any mathematical
expressions can be typed and are evaluated after pressing ↵.
The keys ↑ und ↓ can be used to repeat commands.
The active command line can be edited using the keys ←, → before
being executed by ↵.
Variables and Workspace
At any time, new variables can be generated, and values can be assigned to
variables.
Names of variables must begin with a regular character (or with _). Apart
from this restriction, arbitrary names are allowed.
The operator = is used to assign a value to a variable. Assignment acts
from the right-hand to the left-hand side.
Note: The operator = cannot be used to compare two values
(for this, the operator == is used).
Assigning a new value to an existing variable overwrites its original value.
There is no "undo" function.
If the result of a mathematical expression is not explicitly assigned
to a variable, MATLAB uses a variable called ans.
The actual workspace consists of all present variables and is shown in a
distinct window.
The commands save and load can be used to save the workspace
or parts of it to a file and to reload it, respectively.
The most Important Differences towards Spreadsheet Software (Excel, LibreOffice Calc, ...)
MATLAB variables are not restricted to A1, A2, ...
There is no "German version" with , instead of . as a decimal separator.
In MATLAB, each variable has a value (number, text, ...); MATLAB
does not remember any relationships between variables (expressions).
Functions
MATLAB brings numerous built-in functions.
A function is invoked by its name, followed by a comma-separated list of arguments
enclosed in parentheses, e.g., min(a,b).
Own functions can be defined, too.
Help
helpanything and docanything
provide a description of the respective MATLAB command or function.
Arrays
Beyond single-valued variables, arrays consisting of an almost arbitrary number
of variables can be defined.
One-dimensional arrays are called vectors. Their elements are accessed using one
index, e.g., a(1), a(2), ...
Two-dimensional arrays are denoted matrices. Their elements are accessed using
two indices (row and column), e.g., a(1,1), a(1,2), ..., a(2,1), ...
Almost all useful operations with vectors and matrices are implemented in MATLAB.