Names of variables and functions can contain any characters except the special, but they must begin with a letter. Use a separator, when writing several operators in the same line. Comma serves as delimiter. Delimiter can be omitted after the single or the last operator in a string.
Operators have two forms of recording:
- the implicit assignment (expression);
- with explicit assignment (variable = expression).
When you use the implicit assignment, the system automatically creates a variable called "ans", and assigns it a value of the result.
Command-line buffer length is limited by 256 characters. If you need to move the operator to the next line, you must enter a line continuation character ... (three points), press Enter key to continue the operator. The system uses two types of MATLAB arithmetic operations: on arrays and on matrices; operations on arrays are performed element by element, and on matrices - in accordance with the rules of linear algebra.
The numbers in MATLAB can be represented with a fixed and floating point, be positive or negative, fractional, real and complex.
Features of numbers presentation in MATLAB:
- imaginary unit is represented by two characters "i" and "j";
- integral and fractional parts are separated by point;
- order of the number is separated from mantissa by character "e".
In the process of tasks solving, variables can take up a lot of computer memory. Function "clear" is used in MATLAB to clear the memory from the variables. This function has has such syntax:
- clear х — elimination of "х" variable;
- clear — elimination of all variables;
- clear а b с — elimination of the family of variables.
Constant — is the numerical value of a unique name, which has a mathematical meaning. In MATLAB are often used following constants:
- inf — machine infinity;
- arts — name of the variable, which stores the result of the calculation;
- pi — «number Pi»;
- eps — error in operations with numbers with floating point;
- realmin — minimal number with floating point;
- reaimax — maximal number with floating point;
- NaN — non-numeric character data (Not a Number).
Mathematical functions are represented as fun (x),
where fun — function name,
х — argument as a: number, vector or matrix.
Numbers, elements, vectors or matrix can be real or complex.
For graphing are used special functions.
When you set the style, parameter "s" (vector of constants) is represented as a vector or strings of characters. To set the title of graph, axis labels and grid lines are used such functions: title, xlabel, уlabel, grid on.