General information about MATLAB. Helping mathematicians: MATLAB Matlab overview description

Like most other programming languages, Matlab provides the ability to use mathematical expressions, but unlike many of them, these expressions in Matlab include matrices. The main components of the expression:

Variables;

Operators;

Functions.

Variables. In Matlab, there is no need to define the type of variables or the dimension. When Matlab encounters a new variable name, it automatically creates the variable and allocates the appropriate amount of memory. If the variable already exists, Matlab changes its composition and, if necessary, allocates additional memory. For instance,

num_ students = 25

creates a 1x1 matrix named num_ students and stores the value 25 in its only item.

Variable names consist of letters, numbers, or underscores. Matlab only uses the first 31 characters of a variable name. Matlab is case sensitive, it distinguishes between uppercase and lowercase letters. So A and a is not the same variable. To see the matrix associated with a variable, simply enter the name of the variable.

Numbers. Matlab uses the accepted decimal number system, with an optional decimal point and plus or minus signs for numbers. Scientific number system uses letter e to determine the power factor of ten. Imaginary numbers use i or j as a suffix. Some examples of correct numbers are given below:

All numbers are stored using the format long, these are floating point numbers with a limited precision of approximately 16 significant digits and a limited range of approximately 10 -308 to 10 308.

Operators. Expressions use the usual arithmetic operations and precedence rules (Table 1).

Table 1

Matlab arithmetic operations

Functions. Matlab provides a large number of elementary mathematical functions such as abs, sqrt, exp, sin. Calculating the square root or logarithm of a negative number is not an error: in this case, the result is the corresponding complex number. Matlab also provides more advanced functions, including the Gamma function and Bessel functions. Most of these functions have complex arguments. To list all the elementary math functions, type:

helpelfun

To see a list of all Matlab functions for data analysis:

helpdatafun

If you need to know about StatisticsToolbox, enter:

helpstats

The list of elementary functions is presented in table. 2.

table 2

Elementary functions of the Matlab package

Logarithm of a number to the base :.

To display more complex math and matrix functions, type:

helpspecfun

helpelmat

respectively.

Some features like sqrt and sin, - built-in. They are part of Matlab, so they are very efficient, but their computational details are hard to come by. While other features like gamma and sinh, implemented in m-files. Therefore, you can see their code and, if necessary, even modify it.

Several special functions provide values ​​for commonly used constants:

Infinity appears when dividing by zero or when executing a mathematical expression that leads to overflow, i.e., to exceed realmax. Not a number ( NaN) generated when evaluating expressions like 0/0 or Inf/ Inf that have no specific mathematical meaning.

Function names are not reserved, so it is possible to change their values ​​to new ones, for example:

eps = 1. e-6

cleareps

Relational operators are used to compare two values, vectors or matrices, all relation operators have two comparable values ​​and are written as shown in table. 3.

Posted on http://www.allbest.ru/

Introduction

Matlab package name is short for English Matrix Laboratory(which means matrix laboratory). By the same term (i.e. Matlab) is named and the programming language used for drawing up program codes. As you know, the program code can compile or interpreted... In the first case, we get the executive (machine) code that is executed central processing unit... When interpreting, there is a transformation into intermediate code that is executed directly by the interpreter system. Compiled code usually runs faster than interpreted code. However, interpreted programming languages ​​tend to be more democratic in terms of syntax. Matlab program code is interpreted. However, this does not in any way impair questioned the computational capabilities of Matlab. Basis for implementation different data types in Matlab are matrices, which explains many features of the environment (and programming language) Matlab. To matrices we we will appeal often enough in the course of presenting the material of the book.

Substantial part functionality Matlab application is implemented via tool packages(English term toolbox). These are collections of functions and other utilities designed to solve highly specialized problems. Most packages have a narrow, specific focus. The Matlab application is intended (first of all) for performing numerical calculations and visualizing the results obtained. The package contains a huge number of utilities for performing a wide variety of operations and allows you to create your own fully functional program codes. At the same time, symbolic calculations can be performed in Matlab. The MuPAD environment built into Matlab serves this purpose. So the Matlab user is presented with ample opportunities not only in the field of numerical, but also symbolic calculations.

1. Simple calculations

By simple, or step-by-step, we mean calculations usually performed in the command window of a Matlab application. The corresponding instruction or command is entered in the command window and then executed. Figure 1 shows how the Matlab application window might look at startup. Of interest in this case is the inner window (usually in the center of the application working window) with the name Command Window- command window. In this window, you can see the input line indicator (in the form of a double arrow >> ). To enter a command, the cursor must be moved after the input line indicator and enter the instruction for execution. In other words, an expression must be entered into the input line of the command window and, by pressing the "Enter" key, start the process of calculating this expression. The calculation result is displayed below, under the command being executed. By default, the result is entered into the "ans" system variable.

Picture 1

Figure 2 shows an example of calculating several arithmetic expressions. In this case, the results of calculating the expressions 1 + 2 * 3 and (5 ^ 2-4) / 7 are given, respectively. In the first case, as expected, we get the value 7 as the result, in the second - the value 3.

Picture 2

As the main arithmetic operators in Matlab are used: the operator "+" to calculate the sum, the operator "-" to calculate the difference, the operator "*" to calculate the product, the operator "/" to calculate the quotient and the operator "^" for exponentiation.

In its general sense variable is an area of ​​memory that can be accessed by name to retrieve the value written in this area, as well as change it. In strongly typed programming languages ​​(such as C ++, Java or Pascal), to use a variable, you must first declare it, indicating what type it belongs to. You don't need to do anything like this in Matlab. A variable can be assigned a value right away. The equal sign "=" is used as an assignment operator. The name of the variable to which the value is assigned is indicated to the left of the assignment operator, and the value assigned to the variable is indicated to the right of the assignment operator. The value assigned to the variable if it comes scalar, can be a number or an expression containing other variables. In this case, it is necessary that these variables have already been assigned a value earlier. An example of using scalar variables in incremental calculations is shown in the working paper in Figure 3.

Figure 3

The first command x = 0.5 * sin (0.1) sets the value of the variable "x". In this case, the built-in Matlab function "sin ()" is used to calculate the sine. The value assigned as a result of this variable is displayed below the input line in the format:

« variable =

meaning"

Similarly to the following command y = 0.3 * cos (0.2), the value is assigned to the variable "y". Here "cos ()" is a built-in Matlab function for calculating the cosine. We also draw the attention of the reader that a point is used as a decimal separator when entering real numbers with a fractional decimal part.

Finally, the command z = (x ^ 2 + y ^ 2) ^ (1/3) assigns the value to the variable "z". The expression that determines the value of the variable "z" includes the variables "x" and "y". However, since these variables were previously assigned values, no error occurs and the value of the variable "z" is assigned correctly.

There are two basic operations that are quite useful, especially with a lot of computation. Firstly, in some cases you need to find out which variables of the workspace are already in use, and, secondly, sometimes you have to, figuratively speaking, "delete variables from the playing field" - that is, free the memory allocated for these variables. The first operation is performed using the "whos" statement. If you enter in command line this instruction and press the "Enter" key, a list of variables available in the workspace with a description of some of their attributes will be displayed.

Figure 4

In this case, the list consists of four variables: three declared user variables "x", "y" and "z", and the system variable "ans". The variable space is cleared using the "clear" statement, followed by the names of the variables to be deleted, separated by a space. Figure 5 shows the result of the "clear x y" command followed by the "whos" command to check the list of workspace variables.

Figure 5

Since the “clear x y” command removed the variables “x” and “y” from the workspace, only the variable “z” and the system variable “ans” remained in the list of variables. Although the value of the variable "z" is assigned based on the values ​​of the variables "x" and "y", removing them from the workspace (or changing their value) is not affected by assigning the variable "z". To remove from workspace of all variables use the "clear" statement without specifying variables.

In the previous examples, scalar values ​​were used. In terms of the underlying ideology and technical implementation, scalars in Matlab are exotic rather than commonplace. The fact is that in Matlab the basic data type is matrices (or arrays). In this respect, the scalar "from the point of view of Matlab" (so to speak) is a matrix of size 1x. As you know, arrays can be indexed, that is, to access an array element, the name of the array and its index (or indices) are specified. Indices are indicated after the name of the matrix (array) in parentheses and separated by commas. A scalar variable can be accessed both by name and by specifying indices - in this case, it is (1,1). An example of accessing a scalar in normal mode and using a pair of unit indices is shown in Figure 6.

By the command "MyVar = 10" the variable "MyVar" is assigned the value "10". You can refer to a variable both by the name "MyVar" and in the mode of referring to an element of the matrix "MyVar (1,1)". In both cases, the value of the scalar variable "MyVar" is returned as a result.

Since all variables in Matlab are considered a priori as matrices, you do not need to follow any special instructions when declaring matrices, except that you need to set the values ​​of its elements for the matrix. This is done quite simply. The list of matrix elements is enclosed in square brackets, lists of row element values ​​are separated by commas or spaces, and lists of values ​​for different columns are separated by semicolons. For example, the command "A =" sets a row vector (matrix of dimensions 1x3) with elements "1", "2" and "3", respectively.

Figure 6

The "B =" command sets a column vector (a 3x1 matrix) with elements "4", "5" and "6". Finally, the "C =" command sets a 3x2 matrix (3 rows and 2 columns). Examples of executing these commands are shown in the document in Figure 7.

Figure 7

Matrix elements can be accessed in the usual way by specifying two indices (row number and column number, at the intersection of which the element is located). There is also a way to contact generalized index... The generalized index of a matrix element is defined as its ordinal number, if the counting starts from the top-left element from top to bottom and from the left column to the right. So, if the matrix "X" has dimensions "n" by "m", then the element with indices "i" and "j" can be referred to either as "X (i, j)" or as "X (n * ( j-1) + i) ". While the second way of indexing the elements may seem a little confusing, it follows the technical way of indexing the elements of a matrix in memory, so the calculations are faster in this case. Figure 8 shows a fragment of a document in which, in different mode the elements of the matrix "C" defined earlier are accessed. In particular, with the command "C (1)" we obtain the value of the element "C (1,1)" (value1). The instruction "C (5)" is a reference to the element "C (2,2)", the value of which is "4".

Figure 8

2. Arithmetic operations

The basic arithmetic operators of Matlab allow you to perform operations not only with scalars, but also with matrices. Moreover, it can be argued that the bulk of the operators are focused on executing matrix operations... the main arithmetic operators of Matlab are listed with a brief description of the result of their application to the operands different types(if applicable).

Table 1 Basic arithmetic operators of Matlab.

Operator

Description

Addition operator. The operator is binary. Operands can be both scalar and matrix values. Addition is performed on the two scalar operators. For two matrix operands (matrices of the same size), element-by-element addition is performed: the result is a matrix of the same dimension as the matrix-operands, and its elements are equal to the sum of the corresponding elements of the matrices being added. If one operand is a scalar and the other is a matrix, then the result is a matrix, each element of which is equal to the sum of the scalar and the corresponding element of the matrix operand.

Subtraction operator. Binary operator. The operands can be scalars, matrices of the same size, or a matrix and a scalar. Difference is calculated for scalars. For operands-matrices, a matrix is ​​calculated, the elements of which are equal to the difference between the corresponding elements of the matrix-operands. If one operand is a matrix and the other is a scalar, then the result is a matrix whose elements are calculated as the difference between the corresponding element of the operand matrix and the scalar (taking into account the order of the operands). You can subtract a scalar from a matrix and a matrix from a scalar.

Multiplication operator. Binary operator. If the operands are scalars, the product of the scalars is calculated. For matrix operands, the matrix product is calculated. If one operand is a matrix and the other is a scalar, the result is a matrix whose elements are calculated as the product of the corresponding element of the matrix operand and the scalar.

Division operator. Binary operator. If both operands are scalars, then the quotient of division of the scalar by the scalar is returned as the result. If the first operand is a matrix and the second is a scalar, the result is a matrix, each element of which is obtained by elementwise division of the operand matrix by a scalar. If both operands are square matrices of the same rank, the result is the product of the matrix — the first operand — by the inverse of the matrix — the second operand.

Exponentiation operator. Binary operator. The first operand can be a scalar or square matrix. If the first operand is a scalar, then the second can be any valid scalar. The result is the first operand raised to the power of the second operand. If the first operand is a square matrix, then the second operand must be an integer (can be negative). The result is a matrix calculated by raising the operand matrix to the integer power defined by the second operand.

Left-hand division operator. Binary operator. Operands

are square matrices of the same rank. The result is a matrix equal to the product of the inverse of the first matrix operand and the second matrix operand.

Element multiplication operator. Binary operator. The operands are matrices of the same size. The result is a matrix whose elements are equal to the product of the corresponding elements of the operand matrices.

Element division operator. Binary operator. The operands are matrices of the same size. The result is a matrix whose elements are calculated as the quotient of dividing the elements of the first argument by the corresponding elements of the second argument.

Element-wise left-handed division operator. Binary operator. The operands are matrices of the same size. The result is a matrix of the same size. The division of the elements of the matrix - the second operand - is performed by the corresponding elements of the matrix - the first operand.

The operator for calculating the adjoint matrix. Unary operator. The result is the matrix conjugate to the operator matrix.

Transpose operator. Unary operator. The result is the matrix transposed to the matrix operand.

Element exponentiation operator. Binary operator.

The operands can be scalars or matrices (in different combinations). If the first argument is a matrix, and the second is a scalar or a matrix of the same dimension, then the result is a matrix whose elements are obtained by raising the elements of the first matrix to the power determined by the second scalar operand or the corresponding elements of the second matrix operand. If the first operand is scalar and the second is a matrix, then the result is a matrix the same size as the matrix operand (second). The elements of the result matrix are obtained by raising the scalar (first operand) to the power determined by the corresponding element of the second (matrix) operand.

The above operators almost completely cover the entire range of possible operations that have to be performed with matrices. Some examples of using arithmetic operators with matrix operands are given in Table. 2. Matrices "A" and "B" are initialized in the document with the following commands ( in bold highlighted user input):

>> A =

>> B = [- 1,1; 3, -2]

Table 2 Examples of performing arithmetic operations with matrices.

Description

Product of matrices.

Calculated according to the rules for calculating matrices in linear algebra.

Division of matrices.

Matrix A is multiplied by the inverse of matrix B.

Left-sided matrix multiplication.

The inverse of matrix A is multiplied by matrix B.

Element-wise division of matrices.

The elements of the matrix A are divided by the corresponding elements of the matrix B.

Left-sided element-wise division.

The elements of the matrix B are divided by the corresponding elements of the matrix A.

Element-wise matrix multiplication.

The elements of the matrix A are multiplied by the corresponding elements of the matrix B.

Sum of matrices.

It is calculated according to the rules for calculating the sum of matrices in linear algebra (the corresponding elements of matrices A and B are added).

Difference of matrices.

It is calculated according to the rules for calculating the difference of two matrices (the corresponding elements of matrix B are subtracted from the elements of matrix A).

Matrix transposition.

The result is a matrix transposed to matrix A.

Figure 9

Figure 10

However, arithmetic operators are far from the only operators used in calculations.

3. Logical operators and comparison operators

An important group of operators are logical and comparison operators. Operands in this case can be both scalars and matrices. Before proceeding with the consideration of these operators, let us note some of the peculiarities of working with boolean values.

Usually, boolean values ​​mean a data type, the variables of which can take two values ​​- true and Lying("True" and "false" respectively). In Matlab, any nonzero numeric value is interpreted as true(or "true"), and non-zero values ​​are interpreted as Lying(or "false"). In fact, this is a rule for converting numeric values ​​to logical values. The reverse conversion is performed according to the following rule: boolean true(or "true") is converted to the numeric value "1", and the boolean value Lying(or "false") is converted to the numeric value "0".

If a variable is assigned as a value "true" or "false", the displayed value will be "1" or "0", respectively.

The operands for comparison operators are numeric values. These are binary operators. If both operands are scalars, the comparison is performed according to the rules for comparing numbers. If the ratio is true, the value "1" is returned, if it is false, the value "0" is returned. If the operands are matrices of the same rank, the corresponding elements of the matrices are compared (according to the rules for comparing numeric values). The result is a "logical matrix": its elements are equal to 1 or 0, depending on the result of comparing the corresponding elements of the original matrices. If one operand is a scalar and the other is a matrix, then each element of the matrix is ​​compared with a scalar. Comparison operators are listed in Table 3.binary programming compilation

Table 3 Matlab comparison operators.

Operator

Description

Equality operator.

Operator for checking the values ​​of operands for inequality.

Operator for checking that the value of the first operand is greater than the value of the second operand.

Operator for checking that the value of the first operand is less than the value of the second operand.

Operator for checking that the value of the first operand is not less than the value of the second operand.

Operator for checking that the value of the first operand is not greater than the value of the second operand.

As in the case of comparison operators, both scalars and a matrix (both at the same time or only one) can act as operands of logical operators. If the operands are scalars, the corresponding logical operations are performed according to the rules for converting numeric and boolean values... If both operands are matrices of the same size, logical operations are performed element by element. Provided that one operand is a matrix and the other is a scalar, the logical operation is performed for each element of the matrix and scalar. Matlab logical operators are presented in table 4.

Table 4 Logical operators of Matlab.

Both in comparison operations and in logical operations for matrix elements or scalars (depending on the type of the operands), the return values ​​are "0" (false) and "1" (true).

4. Complex numbers

In Matlab, you can use not only real numbers, but also complex numbers. Complex numbers are entered in the work area in accordance with the rules for representing complex numbers. As an imaginary unit, you can use, optionally, the variables "i" or "j", without any prior announcement. However, if the variable "i" or "j" is assigned a numerical value, the corresponding variable cannot be used as an imaginary unit.

>> z = 1 + 2i

>> z + j

>> (2-4i) * (1 + z)

12.0000 - 4.0000i

>> i* z

When entering a complex value between the imaginary part and the imaginary unit, the multiplication operator can be omitted. By default, the symbol "i" is used to display the imaginary unit (although it can be entered as "j"). There are a number of functions that make it easier to work with complex numbers. Among them, it makes sense to single out the functions "real ()" and "imag ()" for calculating the real and imaginary parts of a complex number, respectively, the function "conj ()" for calculating the complex conjugate number, as well as the function "complex ()", which takes two arguments (real and imaginary parts), based on which the complex number is created.

>> complex (3, -2)

3.0000 - 2.0000i

>> conj (ans)

3.0000 + 2.0000i

>> real (ans)

>> imag(2-4 i)

Not only scalars can be complex, but also matrices.

Figure 11

5. Operator for creating an interval of values

Quite popular and often used in Matlab is the "colon" operator, that is, ":". There are several options for using it. Let's consider the most common ones. To create a row vector with values ​​equally spaced in a certain interval, use the operator in the following format: "lower bound of range, operator (that is,": ") and upper bound of range" - for example: "x = a: b". This creates a row vector (for the above command, the vector is written to the variable "x"). The first element of the vector is equal to the lower limit of the specified range (value "a"). The step of discreteness of changing the values ​​of the vector elements is equal to one. Meaning last item is determined by the upper limit of the specified range (in this case, "b"). So, the command "x = 1: 10" creates a row vector with the values ​​"1, 2, 3, etc." up to 10 "inclusive (user input is highlighted in bold):

>> x = 1: 10

1 2 3 4 5 6 7 8 9 10

Figure 12

If you need to create a row vector with a sequence of values ​​and a step size other than one, use the same "colon" operator (that is, ":"), but in a slightly different format: "the lower limit of the range of values ​​is indicated, the" colon "operator, step of discreteness, again the operator "colon", and the upper limit of the range "- for example:" y = a: m: b ". A row vector is formed with the first value - the lower boundary of the range (for the given command it is "a"). Each next element is obtained by adding to the previous one the value indicated as a step of discreteness (in this case "m"). The values ​​of the elements of the generated array do not exceed the upper limit of the range (that is, "b"). An example of this use of the colon operator is shown below (a code snippet from the workspace, user input is highlighted in bold):

>> y = 1: 0.7: 10

Columns 1 through 8

0000 7000 2.4000 3.1000 3.8000 4.5000 5.2000 5.9000

Columns 9 through 13

6.6000 7.3000 8.0000 8.7000 9.4000

Figure 13

In this case, a row vector y is created with values ​​from 1 to 10 with a discreteness step of 0.7 - values ​​0, 7, 2.4, etc. up to 9.4 inclusive (the next hypothetical value in the sequence 10.1 exceeds the upper limit of the range 10, so it is not included in the generated vector). The messages “Columns 1 through 8” and “Columns 9 through 13” appear automatically as a consequence of the fact that the result of the command “y = 1: 0.7: 10” does not fit into one line, so a part of the result vector is transferred to the next line. These messages are intended to facilitate the process of index identification of elements.

The second way to use the colon operator is when indexing items. As in the previous case, there are several formats, or rules, for using the colon operator in indexes.

For example, if the colon operator is used in the format "A (i: j, k)",

then as a result, a column vector is returned, which is formed from the elements of the matrix "A" located in the "k-th" column from the "i-th" to "j-th" row inclusive. A link in the format "A (:, k)" returns the entire "k-th" column of the matrix "A" as a value.

You can use the colon operator when specifying two indices at once. For example, the command “A (i: j, m: n)” returns a submatrix consisting of rows from “i-th” to “j-th” and simultaneously columns from “m-th” to “n-th”.

Let's look at some examples of using the colon operator.

In particular, the original matrix "A" is entered by the command:

A =

The following commands use the colon operator to extract submatrices from the original matrix "A":

>> A (1: 3.2)

>> A (3.2: 4)

>> A (3: 4.1: 2)

For example, the command "A (1: 3,2)" returns a column vector composed of the elements from the first to the third rows in the second column of the matrix "A". The command "A (3,2: 4)" returns a row vector that is made up of the elements of the third row from the second to the fourth column inclusive of the matrix "A". Finally, the command "A (3: 4.1: 2)" returns the submatrix of the matrix "A", the upper left element of which has indices "(3,1)", and the lower right element has indices "(4,2)".

6. Built-in math functions

A fairly large number of built-in functions are available in Matlab by default. Their core is made up of mathematical functions, which are used relatively often in practice. Some of them are listed in Table 5.

Table 5 Some mathematical functions of Matlab.

Description

The modulus of the number (including the complex one) specified by the function argument.

Arc cosine for the number specified by the function argument.

The arc cosine of the function argument. The result is shown in degrees.

The inverse cotangent of the number specified by the function argument.

The arc cotangent of the function argument. The result is shown in degrees.

The arcsecant of the number specified by the function argument.

The arcsecant of the function argument. The result is presented in degrees.

The arcsecant of the number specified by the function argument.

The arksecant of the function argument. The result is presented in degrees.

The arksecant is hyperbolic of the number specified by the function argument.

Arcsine of the number specified by the function argument.

Arcsine of the function argument. The result is presented in degrees.

The arcsine is hyperbolic of the number specified by the function argument.

The arctangent of the number passed as an argument to the function.

The function has two arguments (for example, atan (y, x)). The result is the direction (angle in the range of values ​​from -p to p) to the point with the corresponding coordinates (in this case, the point with the coordinates (y, x)). If the arguments are complex, their imaginary parts are ignored.

The arctangent of the function argument. The result is shown in degrees.

The arctangent is hyperbolic of the number passed as an argument to the function.

Function of rounding the argument towards plus infinity - rounding is performed to an integer value that is not less than the argument.

The cosine of the number passed as an argument to the function.

The cosine of the function argument, specified in degrees.

The cosine is hyperbolic of the number passed as an argument to the function.

The cotangent of the number passed as an argument to the function.

The cotangent of the function argument, specified in degrees.

The cotangent is hyperbolic of the number passed as an argument to the function.

The cosecant of the number passed as an argument to the function.

The cosecant of the function argument, specified in degrees

The cosecant is hyperbolic of the number passed as an argument to the function.

Exhibitor: exponential function with Euler's constant base and exponent determined by the function argument.

A command of the form expm1 (x) with increased accuracy calculates the value of exp (x) -

The function returns a row vector with prime factors of the number (taking into account their multiplicity) specified by the function argument.

A function for calculating the factorial of the number specified by the function argument.

Rounding function towards zero. The result is a number that is obtained by rounding the function argument to the nearest integer value towards zero.

The function of rounding an argument to the nearest integer value that does not exceed the argument is rounding towards minus infinity.

The function returns the greatest common divisor of integers or integer arrays - the arguments of the function.

The square root of the sum of the squares of the absolute values ​​of the arguments passed to the function.

The function has two arguments. The result is the integer part of separating the first argument by the second. You can also specify an option - in single brackets, the name of the function with which the rounding is performed.

The function returns the least common multiple of integers or integer arrays as the function's arguments.

Natural logarithm of the number specified by the function argument.

Logarithm base 10 of the number specified in the function argument.

A command of the form log1p (x) calculates the value of log (1 + x) with increased accuracy.

Logarithm base 2 of the number specified by the function argument.

The function returns the remainder of dividing the value of the first argument of the function by the value of the second argument. Whole part the branch is determined by the froor () function.

The function returns binomial coefficients as a value. If the function is called in the nchoosek (n, k) format, then the result is returned:,

The function returns the nearest integer as a value - a power of two, which is not less than the modulus of the function argument.

The nthroot (x, n) command returns the nth root (second argument) of a real number or the elements of a real array x (first argument).

The function can be called with one or two arguments. If the function has one argument (array) and the function is called in the format pow2 (x), then an array of powers of two is returned as the result, the exponents are determined by the array x. If the function is called with two arguments in the format pow2 (x, y), the result is x. * 2. ^ y.

The function has two arguments. If the arguments are scalar, the result is the value of the first argument raised to the power specified by the second argument. In more general case"A. ^ B" is returned as the result of the power (A, B) command.

The function generates a list prime numbers... The number of numbers is specified by the function argument.

The function returns the remainder of dividing the value of the first argument of the function by the value of the second argument. The whole part of the branch is determined by the fix () function.

A function to round an argument to the nearest integer value.

Secant of the number specified by the function argument.

The secant of the function argument, specified in degrees.

The sign of the number specified by the function argument (for positive numbers - one, for negative numbers - minus one, for zero - zero).

The sine of the number specified by the function argument.

The sine of the function argument, specified in degrees.

Square root of the number specified by the function argument.

Description

The tangent of the number specified by the function argument.

The tangent of the function argument, specified in degrees.

Although most of the above functions are mathematically defined for scalars, they can usually be used for matrix arguments as well. In this case, the action of the functional operator is applied to each of the matrix elements. For example, if the variable "A" is a matrix with the elements "A (i, j)", then as a result of executing the command "exp (A)" we get a matrix of the same rank, and its elements are calculated as "exp (A (i, j )) ". In some cases, this approach is unacceptable. There are so-called matrix functions, whose arguments, by definition, are matrices (mostly square). The result of these functions is calculated using algorithms developed specifically for matrices. So, Matlab has built-in matrix functions for exponent, logarithm and square root. These are the functions "expm ()", "logm ()" and "sqrtm ()", respectively. For example, if "A" is a square matrix, then the "expm (A)" function calculates the matrix exponent. By definition, this is a series:

The result is a matrix that is usually calculated based on the eigenvalues ​​and eigenvectors of the matrix "A". The matrix logarithm for the matrix argument "A" calculated by the instruction "logm (A)" is a matrix such that the matrix exponent of it is equal to the matrix "A". In other words, by definition, if "B = logm (A)", then "expm (B) = A", and the function "logm ()" is the inverse of the function "expm ()". Likewise, extracting the square root of the matrix "A" using the function "sqrtm ()" produces a matrix that, when squared, gives the matrix "A". For example, if "B = sqrtm (A)" then "B * B = A".

Special functions are also widely represented in Matlab, some of them are shown in Table 6.

Table 6. Some special mathematical functions of Matlab.

Description

Airy function.

Bessel function of the third kind (Hankel function).

The besseli (n, x) command returns the modified Bessel function of the first kind (index n).

The besselj (n, x) command returns the Bessel function of the first kind (index n), which is one of the solutions to the Bessel equation.

The besselk (n, x) command returns the modified Bessel function of the second kind (index n), which is one of the solutions to the modified Bessel equation. For integer indices, the corresponding expression is calculated as a limit.

The besselj (n, x) command returns the Bessel function of the second kind (index n), which is one of the solutions to the Bessel equation. For integer indices, the corresponding expression is calculated as a limit.

Beta Euler function.

Euler's incomplete beta function.

Natural logarithm of Euler's beta function. The arguments are passed to the beta function arguments.

Jacobi elliptic function. If the function is called with two arguments in the format ellipj (u, m), the values ​​(vector) for the functions are returned as the result sn(u) , cn(u) and dn(u).

Function for calculating the complete elliptic integral of the first and second kind (vector of values).

Error function.

Error function (residual).

Error function (residual normalized).

The inverse of the error function erf ().

The inverse of the error function erfc ().

Integral exponent.

Euler's gamma function.

Incomplete gamma function.

Natural logarithm of Euler's gamma function. The argument of the function is passed the argument of the gamma function.

Function for calculating the associated Legendre polynomials. As a result of a function call in the legendre (n, x) format, a column vector of the values ​​of the attached Legendre polynomials is returned m() Pn x for m= 0,1,2,...,n

Psi-polygamous function.

As with basic math functions, for most special functions, matrices can be specified as arguments. In this case, the function is calculated for each of the matrix elements.

7. Numeric data output format

In some cases, you have to change the way the data is displayed on the screen with the result of user commands. First of all, we note that it is possible not to display the result of the command execution in the command window at all. To do this, it is enough to end the corresponding command with a semicolon (that is, ";"). In this case, after pressing the "Enter" key, the command is executed, but the result of its execution is not displayed in the command window. This mode is especially convenient in cases where it is necessary to perform cumbersome intermediate calculations, which, on the one hand, are necessary to obtain the final result, and on the other hand, they clutter working space... Therefore, a reasonable way out of this situation is to hide the result of the command. The numeric output format is explicitly specified using the "format" statement. In the command to define the output format after keyword"Format" indicates the used format. Acceptable formats, with a brief description of them, are listed in Table 7.

Table 7 Number formats.

Description

A numeric display format that displays four digits after the decimal point (fixed point data format). The format is used by default.

Numeric format that displays 7, 14, and 15 digits after the decimal point, depending on the type of numeric data (fixed point data format).

A format for displaying numeric data with a mantissa and exponent (floating point data format) that displays four digits after the decimal point.

Numeric display format with mantissa and exponent (floating point data format), which displays 7, 14, and 15 digits after the decimal point, depending on the type of numeric data.

Depending on the value, either floating point or fixed point format is used for display. Four digits are displayed after the decimal point.

Depending on the value, either floating point or fixed point format is used for display. After the decimal point, 7, 14 or 15 digits are displayed.

Engineering format with four displayed digits after the decimal point and exponent in multiples of three.

Engineering format with 7, 14, or 15 displayed digits after the decimal point and exponent in multiples of three.

A format that displays a + sign for positive numbers, a - sign for negative numbers, and a space for zero.

A financial format that displays two digits after the decimal point.

Display numbers in hexadecimal notation.

Display numbers as a rational fraction.

The mode of displaying the results of calculations in a compact form, with reduced spacing between lines.

The mode of displaying the results of calculations with increased spacing between lines. Used by default.

Below is an example of displaying the number p in different formats (the commands use the built-in constant "Matlab pi"):

>> pi

>> format long

>> pi

3.141592653589793

>> format long e

>> pi

3.141592653589793e + 000

>> format long eng

>> pi

3.14159265358979e + 000

>> format bank

>> pi

>> format rat

>> pi

>> format +

>> pi

Figure 14

Output format settings affect only how numeric values ​​are displayed, not the accuracy of their representation. Therefore, the main criterion when choosing a method for displaying data can be a matter of convenience. There is one function, which, although not directly related to the definition of the format of the output of numerical data, its use greatly facilitates the process of user interaction with the system. This is the "clc" function that allows you to clear the workspace of input commands and results of their execution.

Practicalpart

1. Create a row vector: start element is p, end p, step is 0. Transpose row to column.

2. Create three row vectors of 5 elements fi =, where n = 5 for x = 2, 3, 4. Combine these rows into a matrix A (3 × 5).

3. Create three column vectors from 5 elements of an arithmetic progression. The element of the arithmetic progression is calculated by the formula:

where "an-1" is the previous element; "An" is the next one.

Five elements of the vector are formed, starting with specifying the first element "a" and using the step of the arithmetic progression "d" to specify the following elements:

For the first column vector: a = 2; d = 1:

For the second column vector: a = 7; d = 2:

For the third column vector: a = 10; d = -2:

4. Combine these column vectors into a matrix B (5 × 3).

5. Transpose matrix B and combine with matrix A into matrix M (6 × 5).

6. Remove the second row from the matrix A.

7. In matrix B, zero the third row and remove the last two rows.

8. Create a matrix H (2 × 2) by highlighting the first two rows and columns of the matrix M.

9. Using the repmat function, create a matrix consisting of 2 × 3 H.

10. Create 3 × 3 matrices:

C - units:

F - uniformly distributed random numbers:

E - normally distributed random numbers:

11. Find the minimum element in a 3 × 5 matrix of uniformly distributed numbers using the "reshape" function.

1. Construct on the segment [-1, -0.3] with a step of 0.005 graphs of envelope functions.

The first graph is displayed with a red solid line, and the second - with a green dash-dotted line with marker points x. Then overlay the graphs of discrete readings of the same functions on the resulting graphs without erasing the previous result.

2. Build diagrams of daily temperatures; the values ​​of the vectors of time and temperature for two days are given below.

Time - 0 4 7 9 10 11 12 13 13.5 14 14.5 15 16 17 18 20 22.

Temperature May 10 - 14 15 14 16 18 17 20 22 24 28 25 20 16 13 13 14 13. Temperature May 11 - 12 13 13 14 16 18 20 20 25 25 25 20 16 12 12 11 10.

Design the graphs with the heading "All temperature", sign "Time" on the X-axis; on the Y-axis "Temperature"; in the legend - "10 may", "11 may" and place it in the lower left corner.

3.Plot 3D function plots:

z(x,y) = 4 sin (2p x) cos (5р y)(1 - x 2 )y(1 ?y)

on the rectangular area "x [? 1], y "With a step of 0.05 in all ways considered in laboratory work by placing them in separate areas on the same window. The names of the functions used for plotting the graphs should be included in the titles of these graphs.

Posted on Allbest.ru

...

MATLAB is a high-level technical calculation language, an interactive algorithm development environment and a modern data analysis tool.
MATLAB, in comparison with traditional programming languages ​​(C / C ++, Java, Pascal, FORTRAN), makes it possible to reduce the time for solving typical problems by an order of magnitude and greatly simplifies the development of new algorithms.
MATLAB is the backbone of the entire MathWorks family of products and is the premier tool for solving a wide range of scientific and applied tasks, in such areas as: objects and development of control systems, communication systems, signal and image processing, signal measurement and testing, financial modeling, computational biology, etc.
The MATLAB kernel makes it as easy as possible to work with matrices of real, complex and analytical data types and with data structures and lookup tables. MATLAB contains built-in functions for linear algebra (LAPACK, BLAS), fast Fourier transform (FFTW), functions for working with polynomials, functions of basic statistics and numerical solution of differential equations; extended math libraries for Intel MKL. All of the MATLAB kernel built-in functions are designed and optimized by experts to perform faster or in the same way as their C / C ++ equivalent.

Language Description

MATLAB is a high-level programming language that includes matrix-based data structures, a wide range of functions, an integrated development environment, object-oriented capabilities, and interfaces to programs written in other programming languages.

There are two types of programs written in MATLAB - functions and scripts. Functions have input and output arguments, as well as their own workspace for storing intermediate calculation results and variables. Scripts share a common workspace. Both scripts and functions are not interpreted into machine code and are saved as text files... It is also possible to save the so-called pre-parsed programs - functions and scripts, processed in a form convenient for machine execution. In general, such programs run faster than usual.

The main feature of the MATLAB language is its wide possibilities for working with matrices, which the creators of the language expressed in the slogan Think vectorized.

Mathematics and Computing

MATLAB provides the user with a large number (several hundred) functions for data analysis, covering almost all areas of mathematics, in particular:
Matrices and linear algebra- matrix algebra, linear equations, eigenvalues ​​and vectors, singularities, matrix factorization, and others.
Polynomials and interpolation - roots of polynomials, operations on polynomials and their differentiation, interpolation and extrapolation of curves, and others.
Mathematical statistics and data analysis - statistical functions, statistical regression, digital filtering, fast Fourier transform and others.
Data Processing - a set of special functions, including plotting, optimization, searching for zeros, numerical integration (in quadratures), and others.
Differential equations - solving differential and differential-algebraic equations, differential equations with delay, equations with constraints, partial differential equations, and others.
Sparse matrices are a special MATLAB data class used in specialized applications.
Integer arithmetic - Performs integer arithmetic operations in the MATLAB environment.


Algorithm development

MATLAB provides convenient tools for developing algorithms, including high-level ones using object-oriented programming concepts. It contains all the necessary IDE tools, including a debugger and a profiler. Functions for working with integer data types make it easier to create algorithms for microcontrollers and other applications where necessary.


Data visualization

The MATLAB package contains a large number of functions for plotting graphs, including three-dimensional ones, visual data analysis and creating animated videos.

The built-in development environment allows you to create graphical user interfaces with various controls such as buttons, input fields, and others. Using the MATLAB Compiler component, these graphical interfaces can be converted into stand-alone applications.


External interfaces

The MATLAB package includes various interfaces for accessing external routines written in other programming languages, data, clients and servers communicating through the Component Object Model or Dynamic Data Exchange technologies, and peripherals that communicate directly with MATLAB. Many of these capabilities are known as the MATLAB API.


COM

The MATLAB package provides access to functions that allow you to create, manipulate, and delete COM objects (both clients and servers). ActiveX technology is also supported. All COM objects belong to a special COM class of the MATLAB package. All programs that have Automation controller functions can access MATLAB as an Automation server.


DDE

MATLAB package contains functions that allow it to access other applications Windows environment as well as these applications access MATLAB data through Dynamic Data Exchange (DDE) technology. Each application that can be a DDE server has its own unique identifier name. For MATLAB, this name is Matlab.


Web services

MATLAB provides the ability to call methods of web services. A special function creates a class based on the methods of the web service API.

Matlab interacts with the client of the web service by accepting parcels from him, processing them and sending a response. The following technologies are supported: Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL).


COM port

The MATLAB serial port interface provides direct access to peripheral devices such as modems, printers, and scientific equipment that connect to a computer via a serial port (COM port). An interface works by creating an object of a special class for the serial port. The available methods of this class allow you to read and write data to the serial port, use events and event handlers, and write information to the computer disk in real time. This is useful for experiments, real-time simulations, and other applications.


MEX files

The MATLAB package includes an interface for interacting with external applications written in the C and Fortran languages. This interaction is carried out through MEX files. It is possible to call subroutines written in C or Fortran from MATLAB as if they were built-in functions of the package. MEX files are dynamic link libraries that can be loaded and executed by the interpreter built into MATLAB.


DLL

The MATLAB generic DLL interface allows you to call functions found in ordinary dynamic link libraries directly from MATLAB. These functions must have a C interface.

In addition, MATLAB has the ability to access its built-in functions through a C interface, which allows the package's functions to be used in external applications written in C. This technology is called the C Engine in MATLAB.


Tool kits

For MATLAB, it is possible to create special toolboxes that extend its functionality. Toolkits are collections of functions written in MATLAB to solve a specific class of problems. Mathworks supplies toolkits that are used in many areas, including the following:
Digital processing of signals, images and data: DSP Toolbox, Image Processing Toolbox, Wavelet Toolbox, Communication Toolbox, Filter Design Toolbox - a set of functions that allow you to solve a wide range of problems in signal processing, images, design of digital filters and communication systems.
Control systems: Control Systems Toolbox, µ-Analysis and Synthesis Toolbox, Robust Control Toolbox, System Identification Toolbox, LMI Control Toolbox, Model Predictive Control Toolbox, Model-Based Calibration Toolbox - sets of functions that facilitate the analysis and synthesis of dynamic systems, design, modeling and identification of control systems, including modern control algorithms such as robust control, H∞-control, LMN-synthesis, µ-synthesis, and others.
Financial Analysis: GARCH Toolbox, Fixed-Income Toolbox, Financial Time Series Toolbox, Financial Derivatives Toolbox, Financial Toolbox, Datafeed Toolbox - sets of functions that allow you to quickly and efficiently collect, process and transfer various financial information.
Analysis and synthesis of geographic maps, including three-dimensional: Mapping Toolbox.
Collection and analysis of experimental data: Data Acquisition Toolbox, Image Acquisition Toolbox, Instrument Control Toolbox, Link for Code Composer Studio - sets of functions that allow you to save and process data obtained during experiments, including in real time. A wide range of scientific and engineering measurement equipment is supported.
Data visualization and presentation: Virtual Reality Toolbox - allows you to create interactive worlds and visualize scientific information using technology virtual reality and VRML.
Development tools: MATLAB Builder for COM, MATLAB Builder for Excel, MATLAB Compiler, Filter Design HDL Coder - sets of functions that allow you to create independent applications from the MATLAB environment.
Interaction with external software products: MATLAB Report Generator, Excel Link, Database Toolbox, MATLAB Web Server, Link for ModelSim - sets of functions that allow you to save data to different types so that other programs can work with them.
Databases: Database Toolbox - tools for working with databases.
Scientific and mathematical packages: Bioinformatics Toolbox, Curve Fitting Toolbox, Fixed-Point Toolbox, Fuzzy Logic Toolbox, Genetic Algorithm and Direct Search Toolbox, OPC Toolbox, Optimization Toolbox, Partial Differential Equation Toolbox, Spline Toolbox, Statistic Toolbox, RF Toolbox - sets of specialized mathematical functions that allow solving a wide range of scientific and engineering problems, including the development of genetic algorithms, solving problems in partial derivatives, integer problems, system optimization, and others.
Neural Networks: Neural Network Toolbox - Tools for the synthesis and analysis of neural networks.
Symbolic Math Toolbox Symbolic Math Toolbox - Symbolic calculation tools with the ability to interact with the symbolic Maple program.

Besides the above, there are thousands of other MATLAB toolkits written by other companies and enthusiasts.

Despite the rather high popularity of the MATLAB language, most developers have difficulty understanding both its syntax and capabilities. The thing is that the language is directly related to a popular software product, the cost of which can reach staggering values. So, the main question is: is Matlab itself so good? And can it be useful for you.

Usage

Let's start not with a standard excursion into history and discussion of the pros and cons of the language, but with the MATLAB / Simulink software environment - the only place where the hero of this text can be useful. Just imagine graphics editor, in which you can implement any of your ideas without having several years of experience and appropriate education behind you. And having created a scheme of interaction of tools once, get a high-quality script for repeated use.

MATLAB is just such an editor in the data world. Its scope is infinitely wide: IoT, finance, medicine, space, automation, robotics, wireless systems and much, much more. In general, there are almost unlimited possibilities for collecting and visualizing data, as well as forecasting, but only if there is an opportunity to buy the corresponding package.

As for the price, there is almost no upper border, but the lower one is in the $ 99 region. To grab such a powerful product for relatively little money, you need to be a university student. And of course you get a rather limited product.

Features of the language

The MATLAB language is a tool that allows an operator (often not even a programmer) to interact with all the available capabilities for analyzing, collecting and presenting data. It has obvious pros and cons inherent in a language living in a closed ecosystem.

Flaws:

    A slow and overloaded language with operators, commands, functions, the main purpose of which is to improve visual perception.

    Narrowly directional. There is no other software platform where MATLAB is useful.

    High cost of software. If you are not a student, either get ready to empty your pockets or cross the border of the law. And even if the student is a decent price.

    Low demand. Despite the great interest in MATLAB in almost all areas, in fact and legally only a few use it.

Advantages:

    The language is easy to learn and has a simple and straightforward syntax.

    Huge opportunities. But this is rather an advantage of the entire product as a whole.

    Frequent updates, as a rule, noticeable positive transformations occur at least a couple of times a year.

    Software environment allows you to convert it to "fast" code in C, C ++.

The target audience

Of course, not everyone needs MATLAB. In spite of the broadest region application, it is difficult to imagine that an ordinary application developer might need knowledge of this language. MATLAB is extremely useful in areas that require special reliability in data processing, for example, autopilot systems in cars or airborne electronic systems aircraft.

That is, if you are not a very programmer, but one way or another your profession is associated with the need for programmatic data processing, then the MATLAB / Simulink product with the appropriate language can greatly simplify your everyday tasks.

Literature

We conclude the review of the language, as always, with a list of educational literature. Of course, among them you will not find books exclusively on language, but this will only make the perception of language easier:

Do you have experience with MATLAB? And which?

For those who want to become a programmer -.

    Key features of the packageMatlab

    Package Tool KitsMatlab

    Package structure and working windowsMatlab

    Working in command mode

    Basic elements of the programming languageMatlab

1. Main features of the Matlab package

MATLAB(abbreviated from the English "Matrix Laboratory") - a package of applied programs for solving problems of technical calculations and the programming language of the same name used in this package. MATLAB is used by over 1,000,000 engineers and scientists and runs on most modern operating systems, including Linux, Mac OS, Solaris (Solaris is no longer supported in R2010b), and Microsoft Windows.

Story. MATLAB was developed as a programming language by Cleve Moler in the late 1970s when he was Dean of the Computer Science Department at the University of New Mexico. The purpose of the development was the task of giving the students of the faculty the opportunity to use the Linpack and EISPACK software libraries without the need to study Fortran. Soon the new language spread among other universities and was received with great interest by scientists working in the field of applied mathematics. You can still find the 1982 version of Fortran on the Internet, which is distributed as open source. Engineer John N. (Jack) Little was introduced to this language during a visit by Clive Mowler to Stanford University in 1983. Realizing that the new language had great commercial potential, he teamed up with Cleve Mowler and Steve Bangert. Together, they rewrote MATLAB in C and founded The MathWorks in 1984 for further development. These libraries, rewritten in C, have long been known as JACKPAC. Originally intended for control system design (John Little's main specialty), MATLAB quickly gained popularity in many other scientific and engineering fields. It was also widely used in education, in particular to teach linear algebra and numerical methods.

Description of the MATLAB language. MATLAB language is high-level an interpreted programming language including based on matrices data structures, a wide range of functions, an integrated development environment, object-oriented capabilities and interfaces to programs written in other programming languages.

Programs written in MATLAB are of two types - function and scripts.

Functions have input and output arguments, as well as their own workspace for storing intermediate calculation results and variables.

Scripts share a common workspace. Both scripts and functions are not compiled to machine code and are saved as text files.

It is also possible to save the so-called pre-parsed programs - functions and scripts, processed in a form convenient for machine execution. In general, such programs run faster than normal programs, especially if the function contains graphing commands.

The main feature of the MATLAB language is its extensive capabilities for working with matrices, which the creators of the language expressed in the slogan "think vector" (eng. Think vectorized).

Application of MATLAB.

Mathematics and Computing. MATLAB provides the user with a large number (several hundred) functions for data analysis, covering almost all areas of mathematics, in particular:

    Matrices and linear algebra - matrix algebra, linear equations, eigenvalues ​​and vectors, singularities, matrix factorization, and others.

    Polynomials and interpolation - roots of polynomials, operations on polynomials and their differentiation, interpolation and extrapolation of curves, and others.

    Mathematical statistics and data analysis - statistical functions, statistical regression, digital filtering, fast Fourier transform and others.

    Data Processing - a set of special functions, including plotting, optimization, searching for zeros, numerical integration (in quadratures), and others.

    Differential equations - solving differential and differential-algebraic equations, differential equations with delay, equations with constraints, partial differential equations, and others.

    Sparse matrices are a special MATLAB data class used in specialized applications.

    Integer arithmetic - Performs integer arithmetic operations in the MATLAB environment.

Development of algorithms. MATLAB provides convenient tools for developing algorithms, including high-level ones using object-oriented programming concepts. It contains all the necessary IDE tools, including a debugger and profiler. Functions for working with integer data types make it easier to create algorithms for microcontrollers and other applications where necessary.

Data visualization. The MATLAB package contains a large number of functions for graphing, including three-dimensional, visual data analysis and creating animated videos.

The built-in development environment allows you to create graphical user interfaces with various controls such as buttons, input fields, and others.

Independent applications. MATLAB programs, both console and GUI, can be built using the component MATLAB Compiler into MATLAB-independent executable applications or DLLs that, however, require a free distribution environment to run on other computers MATLAB Compiler Runtime(MCR).

External interfaces. The MATLAB package includes various interfaces for accessing external routines written in other programming languages, data, clients and servers communicating through the Component Object Model or Dynamic Data Exchange technologies, and peripherals that communicate directly with MATLAB. Many of these capabilities are known as the MATLAB API.

COM. The MATLAB package provides access to functions that allow you to create, manipulate, and delete COM objects (both clients and servers). ActiveX technology is also supported. All COM objects belong to a special COM class of the MATLAB package. All programs that have the functions of an automation controller (eng. Automation controller) can access MATLAB as an automation server. Automation server).

.NET. The MATLAB package on Microsoft Windows provides access to the .NET Framework software. It is possible to load .NET Assemblies and work with objects of .NET classes from the MATLAB environment. MATLAB 7.11 (R2010b) supports .NET Framework versions 2.0, 3.0, 3.5, and 4.0.

DDE. The MATLAB package contains functions that allow it to access other Windows applications, as well as these applications to access MATLAB data, through Dynamic Data Exchange (DDE) technology. Each application that can be a DDE server has its own unique identifier name. For MATLAB, this name is - Matlab.

Web services. MATLAB provides the ability to call methods of web services. A special function creates a class based on the methods of the web service API.

MATLAB interacts with a web service client by accepting parcels from it, processing them, and sending a response. The following technologies are supported: Simple Object Access Protocol (SOAP) and Web Services Description Language (WSDL).

COM port. The MATLAB serial port interface provides direct access to peripheral devices such as modems, printers, and scientific equipment that connect to a computer via a serial port (COM port). An interface works by creating an object of a special class for the serial port. The available methods of this class allow you to read and write data to the serial port, use events and event handlers, and write information to the computer disk in real time. This is useful for experiments, real-time simulations, and other applications.

MEX files. The MATLAB package includes an interface for interacting with external applications written in the C and Fortran languages. This interaction is carried out through MEX files. It is possible to call subroutines written in C or Fortran from MATLAB as if they were built-in functions of the package. MEX files are dynamic link libraries that can be loaded and executed by the interpreter built into MATLAB. MEX procedures also have the ability to invoke MATLAB built-in commands.

DLL. The MATLAB generic DLL interface allows you to call functions found in ordinary dynamic link libraries directly from MATLAB. These functions must have a C interface.

In addition, MATLAB has the ability to access its built-in functions through the C interface, which allows the package functions to be used in external applications written in C. This technology in MATLAB is called C Engine.

Alternative packages. There are a large number of software packages for solving numerical analysis problems. Many of these packages are free software.

Compatible with MATLAB at the programming language level:

Similar in functionality:

    APL and its descendants: e.g. J

    Python, when used with the Python (x, y) software package, as well as with libraries such as NumPy, SciPy, and matplotlib, implements similar capabilities.

    IDL (eng. Interactive Data Language, an interactive data description language), which was once a commercial competitor to MATLAB, now remains a serious competitor in many application areas, although its share of the market for numerical analysis software products has plummeted.

    Fortress, a programming language created by Sun Microsystems, inherits, but is not compatible with, Fortran.

    If it is necessary to develop large projects for numerical analysis, it is possible to use general-purpose programming languages ​​that support static typing and a modular structure. Examples include Modula-3, Haskell, Ada, Java. At the same time, it is recommended to use specialized libraries known in the scientific and engineering environment.

2. Matlab toolboxes

In Matlab, an important role is played by specialized groups of programs called toolboxes... Toolboxes are a comprehensive collection of functions (m-files) written in MATLAB for solving a specific class of problems. Mathworks supplies toolkits that are used in many areas, including the following:

    Digital processing of signals, images and data: DSP Toolbox, Image Processing Toolbox, Wavelet Toolbox, Communication Toolbox, Filter Design Toolbox- sets of functions that allow solving a wide range of tasks for signal processing, images, design of digital filters and communication systems.

    Control systems: Control Systems Toolbox, µ-Analysis and Synthesis Toolbox, Robust control toolbox, System Identification Toolbox, LMI Control Toolbox, Model Predictive Control Toolbox, Model-Based Calibration Toolbox- sets of functions that facilitate the analysis and synthesis of dynamic systems, design, modeling and identification of control systems, including modern control algorithms such as robust control, H∞-control, LMN-synthesis, µ-synthesis, others.

    The financial analysis: GARCH Toolbox, Fixed-Income Toolbox, Financial Time Series Toolbox, Financial Derivatives Toolbox, Financial Toolbox, Datafeed Toolbox- sets of functions that allow you to quickly and efficiently collect, process and transfer various financial information.

    Analysis and synthesis of geographic maps, including three-dimensional: Mapping Toolbox.

    Collection and analysis of experimental data: Data Acquisition Toolbox, Image Acquisition Toolbox, Instrument Control Toolbox, Link for Code Composer Studio- sets of functions that allow you to save and process data obtained during experiments, including in real time. A wide range of scientific and engineering measurement equipment is supported.

    Data visualization and presentation: Virtual Reality Toolbox- allows you to create interactive worlds and visualize scientific information using virtual reality technologies and VRML.

    Development tools: MATLAB Builder for COM, MATLAB Builder for Excel, MATLAB Builder for NET, MATLAB Compiler, Filter Design HDL Coder- sets of functions that allow you to create independent applications from the MATLAB environment.

    Interaction with external software products: MATLAB Report Generator, Excel Link, Database toolbox, MATLAB Web Server, Link for ModelSim- sets of functions that allow you to save data in such a way that other programs can work with them.

    Database: Database toolbox- tools for working with databases.

    Science and math packages: Bioinformatics Toolbox, Curve Fitting Toolbox, Fixed-Point Toolbox, Fuzzy Logic Toolbox, Genetic Algorithm and Direct Search Toolbox, OPC Toolbox, Optimization Toolbox, Partial Differential Equation Toolbox, Spline Toolbox, Statistic Toolbox, RF Toolbox- sets of specialized mathematical functions that allow solving a wide range of scientific and engineering problems, including the development of genetic algorithms, solving problems in partial derivatives, integer problems, system optimization, and others.

    Neural networks: Neural Network Toolbox- tools for the synthesis and analysis of neural networks.

    Fuzzy logic: Fuzzy Logic Toolbox- tools for constructing and analyzing fuzzy sets.

    Symbolic computation: Symbolic Math Toolbox- tools for symbolic calculations with the ability to interact with the symbolic processor of the Maple program.

Besides the above, there are thousands of other MATLAB toolkits written by other companies and enthusiasts.

Wi-Fi