How to set up smartphones and PCs. Informational portal
  • home
  • Programs
  • Programming in matlab. Special math functions

Programming in matlab. Special math functions

Lecture 3. Programming in the MATLAB environment.

1. M-files. ................................................. ................................................. ...............................................

1.1. Working in the editor M-files. ................................................. ................................................. ...

1.2. Types of M-files. Program file. ................................................. ...............................................

1.3. Function file. ................................................. ................................................. ...............................

file-functions with one input argument.......................................................................................

file-functions with multiple input arguments........................................................................

file-functions with multiple output arguments.....................................................................

1.4. Subfunctions. ................................................. ................................................. .................................

2. Control structures of the programming language....................................................................

2.1. Loop operators..............................................................................................................................

for loop. ................................................. ................................................. ...............................................

while loop. ................................................. ................................................. ................................................

2.2. Branch operators....................................................................................................................

Conditional operator if . ................................................. ................................................. ...................

switch statement. ................................................. ................................................. ................................

2.3. break , continue and return statements. ................................................. ....................................

2.4. About rational programming techniques in MATLAB........................................................

Many mathematical systems were created based on the assumption that the user would solve their problems with little or no programming. However, it was clear from the outset that similar way has disadvantages and by and large vicious. Many problems require advanced programming tools that make it easier to write their algorithms and sometimes open up new methods for creating them.

On the one hand, MATLAB contains a huge number of built-in operators and functions (approaching a thousand) that successfully solve many practical problems, for which quite complex programs had to be prepared earlier. For example, these are the functions of inverting or transposing matrices, calculating the values ​​of a derivative or integral, etc., etc. The number of such functions, taking into account the system expansion packages, already reaches many thousands and is constantly increasing. But, on the other hand, the MATLAB system from the moment of its inception was created as a powerful mathematical programming language focused on technical calculations. high level. And many quite rightly regarded this as an important advantage of the system, indicating the possibility of its application to solve new, most complex mathematical problems.

The MATLAB system has an input language reminiscent of BASIC (with an admixture of Fortran and Pascal). Writing programs in the system is traditional and therefore familiar to most computer users. In addition, the system makes it possible to edit programs using any text editor familiar to the user. It also has its own editor with a debugger. The language of the MATLAB system in terms of programming mathematical calculations is much richer than any universal language high level programming. It implements almost all known programming tools, including object-oriented and visual programming. This gives experienced programmers immense opportunities for self-expression.

1. M-files.

IN In previous lectures, we looked at fairly simple examples that require typing a few commands on the command line to execute. For more challenging tasks the number of commands increases, and work on the command line becomes unproductive. Using command history,

saving work environment variables or journaling with diary is negligible

increase work productivity. An effective solution is to design your own algorithms in the form of programs (M-files) that can be run from the working environment or from the editor. The built-in M-file editor in MATLAB allows not only typing the text of the program and running it in whole or in part, but also debugging the algorithm. A detailed classification of M-files is given below.

1.1. Work in the M-file editor.

A special multi-window editor is used to prepare, edit and debug m-files. It is designed like a typical Windows application. The editor can be called by the edit command from the command line or by the main menu command File | New | M file . After that, you can create your own file in the editor window, use the tools for debugging and launching it. Before a file can be run, it must be written to disk using the File | Save as in the editor menu.

Figure 1 shows the editor/debugger window. The prepared text of the file (this is the simplest and our first program in the MATLAB programming language) can be written to disk. For this, the Save As command is used, which uses standard window Windows to write a file with given name. It should be noted that the M-file name must be unique, and the requirement for a file name is the same as for names environment variables MATLAB. After writing the file to disk, you can run the Run command from the toolbar or the Debug menu, or simply press ., in order to execute the m-file.

At first glance, it may seem that the editor / debugger is just an extra link in the "user - MATLAB" chain. Indeed, the text of the file could be entered into the system window and get the same result. However, in reality, the editor/debugger plays an important role. It allows you to create an m-file (program) without the numerous "husks" that accompanies work in command mode. The text of such a file is subjected to a thorough syntactic check, during which many user errors are identified and eliminated. Thus, the editor provides syntactic control of the file.

The editor has other important debugging tools - it allows you to set special marks in the text of the file, called breakpoints (breakpoints). When they are reached, the calculations are suspended, and the user can evaluate the intermediate results of calculations (for example, the values ​​of variables), check the correct execution of loops, etc. Finally, the editor allows you to write a file in text format and perpetuate your work in the MATLAB file system.

For the convenience of working with the editor/debugger, the program lines are numbered in sequential order. The editor is multiwindow. The window of each program is designed as a tab. The debugger editor makes it easy to view the values ​​of variables. To do this, just move the mouse cursor to the name of the variable and hold it - a tooltip with the name of the variable and its value will appear.

A very convenient feature of the M-file editor is execution of some commands. To do this, use the Evaluate Selection command from the context menu or the main menu Text , or simply the function key , which allow you to execute the selected program text.

Rice. 1. M-file editor window.

1.2. Types of M-files. Program file.

There are two types of M-files in MATLAB: Script M-Files, containing a sequence of commands, and Function M-Files, which describe user-defined functions.

File-programs are the simplest type of M-files. They have no input or output arguments and operate on variables that exist in the runtime or may create new variables. You wrote the mydemo program file when you read the previous section. All variables declared in a file-program become available in the working environment after its execution. Run the mydemo program file shown in Listing Figure 1. Go to the Workspace window and make sure that all the variables entered in the M-file appear in the workspace. All variables created during the execution of the M-file remain in the working environment after its completion, and they can be used in other file programs and in commands executed from the command line.

The file program is launched in two ways.

1. From the M-file editor as described above.

2. From command line or other program file, while the command is the name of the M-file (without extension). The use of the second method is much more convenient, especially if the created program file will be repeatedly used later. The M-file actually created becomes a command that MATLAB understands.

Close all graphical windows and type mydemo at the command line, a graphical window appears corresponding to the commands of the mydemo.m program file. After you enter the command mydemo, MATLAB does the following:

1. Checks if the given command is a name any of the variables defined

in working environment. If a variable is entered, its value is displayed.

2. If the input is not a variable, then MATLAB searches for the input command among the built-in functions. If the command is a built-in function, then it is executed.

3. If the input is neither a variable nor a built-in function, then MATLAB starts searching M-file with the name of the command and the extension m. Search starts with current directory(Current Directory); if the M-file is not found in it, then MATLAB searches the directories set in the search path (Path). (To set the current directory, you can use the selection box of the same name on the toolbar or the cd command. Setting search paths is done with

using the Set Path command of the File menu command or using the addpath command).

If none of the above actions was successful, then a message is displayed in the command window, for example, if a mistake is made.

The MATLAB search sequence tells you that it is very important to correctly name your own program file when saving it in an M-file. First, its name must not match the name of existing functions in MATLAB. You can find out if the name is already occupied or not with the help of the function 'exist'.

Secondly, the file name must not start with a digit, "+" or "-" characters, a word with those characters that can be interpreted by MATLAB as an error when entering an expression. For example, if you name the M-file with the program file 5prog.m, then when you start it from the editor menu or by get an error message. This is not surprising since MATLAB expects 5 + prog (or 5, prog) from you to evaluate an arithmetic expression with variable prog (or add 5 as the first element to prog's row vector). Therefore, the correct name would be prog5.m (or at least p5rog.m), but only starting with a letter.

Please note that if you run the selected commands (all commands can be selected) of an M-file with the wrong name with , then there will be no error. In fact, there is a sequential execution of commands, which does not differ from calling them from the command line, and not the work of a file program.

There is another very common mistake when naming a file-program, which at first glance has inexplicable consequences: the program is launched only once. Restart does not cause the program to execute. Let's look at this situation using the program file in listing 5.1, which you saved in the file mydemo.m. Rename the file to x.m, then remove all workspace variables from the Workspace Variables Browser window or from the command line:

>> clear all

Execute the program file, for example, from the editor by pressing . A graphics window appears with two graphs and nothing portends a dirty trick. Close the graphics window now and run the program again. The graphics window is no longer created, but the values ​​of the x array are displayed in the command window in accordance with the first paragraph of the MATLAB search algorithm above. These circumstances should be taken into account when choosing a file program name. An equally important issue is related to the third item of the MATLAB search algorithm - the current directory and search paths. As a rule, own M-files are stored in user directories. In order for MATLAB to find them, paths must be set to indicate the location of the M-files.

1.3. Function file.

The file programs discussed above are a sequence of MATLAB commands, they have no input or output arguments. To solve computational problems and write your own applications in MATLAB, you often need to program file functions that perform the necessary actions on input arguments and return the result in output arguments. The number of input and output arguments depends on the problem being solved - there can be only one input and one output argument, several of both, or only input arguments.

It is possible that there are no input and output arguments. This section provides some simple examples to help you understand how to work with file functions. Function files, like program files, are created in the M-file editor.

Function file with one input argument.

Let's assume that in calculations it is often necessary to use the value of a function:

− xx 2

It makes sense to write a function file once, and then call it wherever it is necessary to evaluate this function for a given argument. To do this, you need to open in the M-file editor new file and type text:

function f = myfun(x)

The word function in the first line specifies that given file contains a function file. The first line is function header, which contains the function name and lists of input and output arguments. Input arguments are written in parentheses after the function name. In our example, there is only one input argument, x. The output argument f is specified to the left of the equals sign in the function header. When choosing a function file name, care must be taken not to conflict with occupied names in MATLAB. We discussed a similar question above: how to save a program file in a file with a unique name. You can use the same exist function call approach to name a function file.

After the header, the body of the file function is placed - one or several operators (there may be quite a lot of them) that implement the algorithm for obtaining the value of the output variables from the input ones. In our example, the algorithm is simple - an arithmetic expression is calculated for a given x and the result is written to f.

Now you need to save the file in the working directory or some other location known to MATLAB. When you select Save or Save as... from the File menu, the default file name is the same as the name of the myfun function. You must save the function file with this suggested name. Now the created function can be used in the same way as the built-in sin, cos and others, for example, from the command line:

>> y=myfun(1.3) y=

When creating the file function myfun, we suppressed the output of the value of f to the command window by ending the assignment statement with a semicolon. If this is not done, then it will be displayed when y=myfun(1.3) is called. As a rule, it is better to avoid outputting to the command window the results of intermediate calculations inside a file function.

The file function shown in the previous example has one significant drawback. Attempting to calculate function values ​​from an array results in an error, not an array of values, as happens when using built-in functions.

>>x=;

>> y=myfun(x)

??? Error using ==> ^ Matrix must be square.

Error in ==> C:\MATLAB6p5\work\myfun.m

On line 2 ==> f = exp(-x)*sqrt((x^2 + 1)/(x^4 + 0.1));

Obviously, to avoid this error, it is necessary to use element-wise operations. In particular, for the correct operation of our function, it is necessary to rewrite the text of the function in the following form:

function f = myfun(x)

f = exp(-x).*sqrt((x.^2 + 1)./(x.^4 + 0.1));

Now the argument of the myfun function can be either a number or a vector or matrix of values, for example:

>>x=;

>> y=myfun(x)

The variable y , into which the result of calling the myfun function is written, automatically becomes a vector of the required size.

Let's look at an example of using functions. We plot the myfun function on a segment using a file program or from the command line:

>> x=0:0.5:4;

>> y=myfun(x);

>>plot(x,y)

Solving computational problems using MATLAB will require you to be able to program file functions that correspond to the task (for example, the right side of the system differential equations or an integrand).

We will now look at just one simple example of how the use of file functions simplifies the visualization of mathematical functions. We have just plotted with plot . Note that it was not necessary to call myfun to calculate the vector y - you could write an expression for it right away and then specify the x and y pair in plot . The file function myfun that we have at our disposal allows us to refer to the special function fplot , which needs to specify the name of our file function (in apostrophes) or a pointer to it (with the @ operator in front of the function name) and the boundaries of the segment for plotting (in a vector of two elements )

>>fplot("myfun", )

>> fplot(@myfun, )

The algorithm of the fplot function should be added to automatically select the argument step, reducing it in areas of rapid change in the function under study, which gives the user a good display of data.

Function file with multiple input arguments.

Writing file functions with multiple input arguments is almost the same as writing a single argument. All input arguments are placed in a comma-separated list. The following example contains a function file that calculates the length of the radius vector of a 3D point.

spaces x 2 + y 2 + z 2 .

function r = radius3(x,y,z) r = sqrt(x.^2 + y.^2 + z.^2);

>> R = radius3(1, 1, 1)

In addition to functions with multiple arguments, MATLAB allows you to create functions that return multiple values, i.e., have multiple output arguments.

Function file with multiple output arguments.

File functions with multiple output arguments are useful for evaluating functions that return multiple values ​​(called vector functions in mathematics). The output arguments are added, separated by commas, to the list of output arguments, and the list itself is enclosed in square brackets. The following example gives the hms function file to convert a time given in seconds to hours, minutes, and seconds:

function = hms(sec) hour = floor(sec/3600);

When calling file functions with multiple output arguments, the result should be written to a vector of the appropriate length:

>> = hms(10000) h =

If you do not explicitly specify output parameters when using this function, then the result of the function call will be only the first output argument:

>> hms(10000) ans =

If the list of output arguments is empty, i.e. the header looks like this: function myfun(a, b) or function = myfun(a, b) .

then the function file will not return any values. Such functions are also sometimes useful.

MATLAB functions have another useful feature - the ability to obtain information about them using the help command, for example, help fplot . Own file functions can also be endowed with this property using comment lines. All comment lines after the header and before the body of the function or an empty line are displayed in the command window with the help command. For example, for our function, you can create a hint:

function = hms(sec) %hms - convert seconds to hours, minutes and seconds

% The hms function is for converting seconds

% in hours, minutes and seconds.

% = hms(sec)

hour = floor(sec/3600);

minute = floor((sec - hour*3600)/60); second = sec - hour*3600 - minute*60;

1.4. Subfunctions.

Consider another kind of functions - subfunctions. The use of subfunctions is based on separating a part of the algorithm into an independent function, the text of which is contained in the same file as the main function. Let's look at this with an example.

function simple;

% Main function a = 2*pi;

fl = f(1.1, 2.1) f2 = f(3.1, 4.2)-a f3 = f(-2.8, 0.7)+a

function z = f(x, y)% Subfunction

z = x^3 - 2*y^3 - x*y + 9;

The first simple function is main function in simple.m , it is its statements that are executed if the user calls simple , for example from the command line. Each call to the subfunction f in the main function leads to a transition to the operators placed in the subfunction and a subsequent return to the main function.

A function file can contain one or more subfunctions with their own input and output parameters, but there can be only one main function. The title of the new subfunction is also a sign of the end of the previous one. The main function communicates with subfunctions only through input and output parameters. Variables defined in subfunctions and in the main function are local, they are available within their function.

One of options The use of variables that are common to all M-file functions consists in declaring these variables at the beginning of the main function and subfunction as global, using global with a space-separated list of variable names.

2. Control structures of the programming language.

The file functions and file programs that you created in the previous two chapters are the simplest examples of programs. All MATLAB commands contained within them are executed sequentially. To solve many more serious problems, programs are required in which actions are repeated cyclically, and depending on certain conditions, different parts of the program are executed. This chapter describes the control constructs of the MATLAB programming language that can be used when writing both file programs and file functions.

2.1. Loop operators.

Similar and repetitive actions are performed using the for and while loop statements. The for loop is designed to perform a predetermined number of repetitive actions, a while - for actions whose number is not known in advance, but the condition for continuing the loop is known.

for loop.

The use of for is as follows:

for count = start:step:final

MATLAB commands

Here count is a loop variable, start is its initial value, final is the final value, astep is the step by which count is incremented each time the loop is entered. The loop ends as soon as the value of count becomes greater than final . The loop variable can take not only integer values, but also real values ​​of any sign. Here is an example of using the for loop. Let it be required to display graphs of a family of curves for x , which

is given by the function y (x ,a )= e − ax sinx , depending on the parameter a , for the values ​​of the parameter a from -0.1 to

0.1 in increments of 0.02. You can, of course, sequentially calculate y(x, a) and plot its graphs for different values, but it is much more convenient to use the for loop. Text file-program:

figure % create graphics window

x = 0:pi/30:2*pi; % calculation of the vector of argument values

% enumerating parameter values ​​in a loop for a = -0.1:0.02:0.1

% calculating the vector of function values ​​for the current value...

parameter

y = exp(-a*x).*sin(x); % add graph of hold on function

plot(x, y) end

As a result of the execution of this file program, a graphical window will appear, shown in Fig. 2, which contains the required family of curves.

Rice. 2. Family of curves.

For loops can be nested within each other, but the variables of the nested loops must be different. Nested loops are convenient for filling matrices. An example of creating a Hilbert matrix:

a = zeros(n); for i = 1:n

for j = 1:n

a(i, j) = 1/(i+j-1);

In conclusion of this section, we note one more feature of the for loop, which, along with the ability to set a real loop counter with a constant step, makes the for loop quite versatile. An array of values ​​can be used as the values ​​of a loop variable:

for count = A

MATLAB commands

If A is a row vector, then count sequentially takes the value of its elements each time it enters the loop. In the case of a two-dimensional array A, at the i -th step of the loop, count contains the column A(:,i) . Of course, if A is a column vector, then the loop will execute only once with count equal to A .

The for loop is useful when doing a certain finite number of things. There are algorithms with a previously unknown number of repetitions, which can be implemented with a more flexible while loop.

while loop.

The while loop is used to organize repetitions of the same type of actions in the case when the number of repetitions is not known in advance and is determined by the fulfillment of a certain condition. Consider the example of expanding sin(x) into a series:

x 2k + 1

S(x)=∑(−1)

(2k + 1) !

k = 0

Of course, it will not be possible to sum up to infinity, but it is possible to accumulate the sum with a given accuracy, for example, 10-10. Obviously, the number of members of the series is unknown in this case, so the use of the for operator is not possible. The solution is to use a while loop that runs as long as the condition of the loop is true:

while loop repeat condition

MATLAB commands

IN In this example, the condition for repeating the cycle is that the modulus of the current term

x 2 k + 1 (2k + 1) ! more than 10-10. The text of the mysin function file that calculates the sum of a series based on

recurrent relation:

k − 1

2k (2k + 1)

function s = mysin(x)

% Calculation of the sine by series expansion

% Usage: y = mysin(x),-pi< х < pi

% calculation of the first summand for k = 0 k = 0;

% auxiliary variable calculation

while abs(u) > 1.0e-10 k = k + 1;

u = -u* x2/(2*k)/(2*k + 1); s = s + u

This window is the main one in MatLAB. It displays command symbols that are typed by the user on the display screen, displays the results of these commands, the text of the executable program and information about program execution errors recognized by the system.

A sign that MatLAB is ready to accept and execute the next command is the occurrence in the last line text field prompt box ">>" followed by a blinking vertical bar.

At the top of the window (under the title) there is a menu bar containing the File, Edit, View, Windows, Help menus. To open any menu, place the mouse pointer on it and press its left button. The functions of the menu commands will be described in more detail later, in the section “MatLab interface and commands general purpose. Writing M-books.

Here we only note that to exit the environment MatLAB, it is enough to open the File menu and select the Exit MATLAB command in it, or simply close the command window by pressing the left mouse button when the mouse cursor is positioned on the image of the top rightmost button of this window (indicated by an oblique cross).

1.2. Operations with numbers

1.2.1. Entering real numbers

Entering numbers from the keyboard is carried out according to the general rules adopted for high-level programming languages:

a decimal point is used to separate the fractional part of the mantissa of a number (instead of a comma in normal notation);

the decimal exponent of the number is written as an integer after the previous entry of the character "e";

between the mantissa of a number and the symbol "e"(which separates the mantissa from the exponent) there shouldn't be any characters, including the space character.

If, for example, you enter the line in the MatLAB command window

then after pressing the key<Еnter>This window will display:


It should be noted that the result is output in the form (format), which is determined by the preset number format. This format can be set with the command Preferences menu File(Fig. 1.3). After calling it, a window of the same name will appear on the screen (Fig. 1.4). One of the sections of this window has the title Numeric Format. It is intended for setting and changing the format of representation of numbers that are displayed in the command window during calculations. The following formats are provided:

Short (default) – short entry (used by default);

Long - long record;

Hex - record as a hexadecimal number;

Bank - record up to hundredths;

Plus - only the sign of the number is written;

Short E - short record in floating point format;

Long E - long record in floating point format;

Short G - second form abbreviation in floating point format;

Long G is the second form of long floating point notation;

Rational - notation in the form of a rational fraction.

Selecting with the mouse desired view representation of numbers, it is possible to provide further display of numbers in the command window in this form.

As can be seen from fig. 1.2, the number that is displayed on the screen does not match the entered one. This is because the default number format ( Short) does not allow output more than 6 significant figures. In fact, the entered number is stored inside MatLAB with all its entered digits. For example, if you select the Long selector button with the mouse E(i.e., set the specified format for representing numbers), then, repeating the same steps, we get:

where all the numbers are already displayed correctly (Fig. 1.5).

It should be remembered:

- the entered number and the results of all calculations in the Ma system tLAB stored in the PC memory with a relative error of about 2.10-16(i.e. with exact values ​​in 15 decimal places):

- the representation range of the modulus of real numbers lies between 10-308 and 10+308 .

1.2.2. The simplest arithmetic operations

In the arithmetic expressions of the MatLAB language, the following signs of arithmetic operations are used:

+ - addition;

- - subtraction;

* - multiplication;

/ - division from left to right;

\ - division from right to left;

^ - exponentiation.

Using MatLAB in calculator mode can be done by simply writing in command line sequences of arithmetic operations with numbers, that is, an ordinary arithmetic expression, for example: 4.5 ^ 2 * 7.23 - 3.14 * 10.4.

If, after entering this sequence from the keyboard, you press the key , the result of execution will appear in the command window in the form shown in Fig. 1.6, i.e., the result of the action of the last executed statement is displayed on the screen under the name of the ans system variable.

In general, the output of intermediate information to the command window obeys the following rules:

- if the statement entry does not end with a character";", the result of the action of this operator is immediately displayed in the command window;

- if the statement ends with a character";", the result of its action is not displayed in the command window;

- if the statement does not contain an assignment sign(= ), i.e. is simply a record of some sequence of operations on numbers and variables, the result value is assigned to a special system variable named ans ;

- received variable value ans can be used in the following calculation statements using this name ans; it should be remembered that the value of the system variable ans changes after the action of the next operator without an assignment sign;

- in the general case, the form for presenting the result in the command window looks like:

<Имя переменной> = <результат>.

Example. Let it be necessary to calculate the expression (25+17)*7. It can be done in this way. First, we type the sequence 25 + 17 and press . We get the result on the screen in the form ans = 42. Now write the sequence ans*7 and press . We get ans = 294 (Fig. 1.7). To prevent the output of the intermediate result of the action 25+17, it is enough to add the character ";" after writing this sequence. Then we will have results in the form shown in Fig. 1.8.

Using MatLAB as a calculator, you can use variable names to write intermediate results to the PC's memory. For this, the assignment operator is used, which is introduced by the equals sign "=" in accordance with the scheme:<Имя переменной> = <выражение>[;]

The variable name can be up to 30 characters long and must not be the same as the names of functions, system procedures, and system variables. The system distinguishes between uppercase and lowercase letters in variables. So, the names "amenu", "Amenu", "aMenu" in MatLAB denote different variables.

The expression to the right of the assignment sign can be just a number, an arithmetic expression, a character string (then these characters must be enclosed in apostrophes), or a character expression. If the expression does not end with ";", after pressing the key<Еnter>in the command window, the result of execution will appear in the form:

<Variable name> = <result>.

Rice. 1.7. Rice. 1.8.

For example, if you enter the line " X= 25 + 17", a record will appear on the screen (Fig. 1.9).

The MatLAB system has several variable names that are used by the system itself and are part of the reserved ones:

i, j – imaginary unit (square root of –1); pi is the p number (stored as 3.141592653589793); inf - designation of machine infinity; Na - designation of an indefinite result (for example, type 0/0 or inf/inf); eps is the error of operations on floating point numbers; ans is the result of the last operation without an assignment sign; realmax and realmin are the maximum and minimum possible values ​​of the number that can be used.

These variables can be used in mathematical expressions.

1.2.3. Entering complex numbers

The language of the MatLAB system, unlike many high-level programming languages, contains a very easy-to-use built-in complex number arithmetic. Most elementary mathematical functions accept complex numbers as arguments, and the results are generated as complex numbers. This feature of the language makes it very convenient and useful for engineers and scientists.

Two names i and j are reserved for the imaginary unit in the MatLAB language. The input from the keyboard of the value of a complex number is carried out by writing to the command window a line of the form:

<complex variable name> = <DC value> + i[j] * <MCH value>,

where DC is the real part of the complex number, MS is the imaginary part. For example:

The above example shows how the system displays complex numbers on the screen (and on print).

1.2.4. Elementary math functions

The general form of using a function in MatLAB is:

<result name> = <function name>(<list of arguments or their values>).

The MatLAB language provides the following elementary arithmetic functions.

Trigonometric and hyperbolic functions

sin (z) is the sine of the number z;

sinh(z) – hyperbolic sine;

asin (z) - arcsine (in radians, in the range from to );

butsinh(z) – inverse hyperbolic sine;

cos(z) - cosine;

сsh(z) – hyperbolic cosine;

acos (z) - arc cosine (in the range from 0 to p);

asosh(z) is the inverse hyperbolic cosine;

tan (z) – tangent;

tanh (z) – hyperbolic tangent;

atan (z) – arc tangent (in the range from to );

atap2 (X, Y) – four-quadrant arc tangent (angle in the range from – p to + p between the horizontal right ray and the ray that passes through the point with coordinates X And Y);

atanh (z) is the inverse hyperbolic tangent;

sec (z) – secant;

sech (z) is the hyperbolic secant;

asec (z) – arcsecant;

asech (z) is the inverse hyperbolic secant;

csc (z) is the cosecant;

csch (z) is the hyperbolic cosecant;

acsc (z) is the arc cosecant;

acsch (z) is the inverse hyperbolic cosecant;

cot (z) – cotangent;

coth (z) is the hyperbolic cotangent;

acot (z) – arc tangent;

acoth (z) – inverse hyperbolic cotangent

Exponential Functions

exp (z) is the exponent of the number z;

log(z) is the natural logarithm;

log10 (z) – decimal logarithm;

sqrt(z) is the square root of z;

abs (z) is the modulus of the number z.

Integer functions

fix (z) - rounding to the nearest integer towards zero;

floor (z) - rounding to the nearest integer towards negative infinity;

ceil (z) - rounding to the nearest integer towards positive infinity;

round (z) - the usual rounding of the number z to the nearest integer;

mod (X, Y) – integer division of X by Y;

rem(X, Y) - calculation of the remainder after dividing X by Y;

sign(z) – calculation of the signum function of the number z

(0 at z = 0, –1 at z< 0, 1 при z > 0)

1.2.5. Special math functions

In addition to the elementary ones, the MatLAB language provides a number of special mathematical functions. Below is a list and summary of these functions. The user can find the rules for accessing and using them in the descriptions of these functions, which are displayed by typing the help command and specifying the function name in the same line.

Coordinate transformation functions

cart2 sp– transformation of Cartesian coordinates into spherical ones;

cart2 pol– transformation of Cartesian coordinates into polar ones;

pol2 cart– transformation of polar coordinates into Cartesian ones;

sp2 cart– transformation of spherical coordinates into Cartesian ones.

Bessel functions

besselj is the Bessel function of the first kind;

bessely is the Bessel function of the second kind;

besseli is the modified Bessel function of the first kind;

besselk is a modified Bessel function of the second kind.

Beta Features

beta– beta function;

betainc– incomplete beta function;

betaln is the logarithm of the beta function.

Gamma functions

gamma is the gamma function;

gammainc– incomplete gamma function;

gammaln is the logarithm of the gamma function.

Elliptic functions and integrals

ellipj are Jacobi elliptic functions;

ellipke is the complete elliptic integral;

expint is the exponential integral function.

Error functions

erf is the error function;

erfc– additional error function;

erfcx is the scaled additional error function;

erflnv is the inverse error function.

Other features

gcd is the greatest common divisor;

lern is the least common multiple;

legendre is the generalized Legendre function;

log2– logarithm base 2;

pow2– raising 2 to the specified power;

rat- representation of a number as a rational fraction;

rats- representation of numbers as a rational fraction.

1.2.6. Elementary actions with complex numbers

The simplest operations with complex numbers - addition, subtraction, multiplication, division and exponentiation - are carried out using the usual arithmetic signs +, -, *, /, \ and ^, respectively.

Examples of use are shown in fig. 1.11.

Note. The above snippet uses the function disp (from the word "display"), which also displays the results of calculations or some text in the command window. In this case, the numerical result, as can be seen, is already displayed without specifying the name of the variable or ans.

1.2.7. Complex Argument Functions

Almost all elementary mathematical functions given in paragraph 1.2.4, are calculated with complex values ​​of the argument and obtain as a result of this the complex values ​​of the result.

Due to this, for example, the sqrt function calculates, unlike other programming languages, the square root of a negative argument, and the function abs with a complex value of the argument, calculates the modulus of the complex number. Examples are shown in fig. 1.12.

There are several additional functions in MatLAB that only take a complex argument:

real (z) - highlights the real part of the complex argument z;

і mag (z) - extracts the imaginary part of the complex argument;

angle (z) - calculates the value of the argument of the complex number z (in radians in the range from -p to +p);

conj (z) - returns the number complex conjugate with respect to z.

Examples are shown in fig. 1.13.

Rice. 1.12. Rice. 1.3.

In addition, MatLAB has a special function cplxpair (V), which sorts a given vector V with complex elements in such a way that the complex conjugate pairs of these elements are located in the result vector in ascending order of their real parts, while the element with negative imaginary part is always placed first. Real elements complete complex conjugate pairs. For example, in further in the examples of commands that are typed from the keyboard, will be in bold, and the result of their execution is in normal font):

>> v = [-1, -1+2i,-5,4,5i,-1-2i,-5i]

Columns 1 through 4

1.0000 -1.0000 +2.0000i -5.0000 4.0000

Columns 5 through 7

0 + 5.0000i -1.0000-2.0000i 0 - 5.0000i

>>disp(cplxpair(v))

Columns 1 through 4

1.0000 - 2.0000i -1.0000 + 2.0000i 0 - 5.0000i 0 + 5.0000i

Columns 5 through 7

5.0000 -1.0000 4.0000

The adaptation of most MatLAB functions to operate with complex numbers makes it much easier to build calculations with real numbers, the result of which is complex, for example, to find the complex roots of quadratic equations.

1. A. K. Gultyaev, MatLAB 5.2. Simulation modeling in the Windows environment: Practical guide. - St. Petersburg: CROWN print, 1999. - 288 p.

2. Gultyaev A. K. Visual modeling in the MATLAB environment: Training course. - St. Petersburg: PETER, 2000. - 430 p.

3. Dyakonov V. P. Handbook on the use of the PC MatLAB system. - M.: Fizmatlit, 1993. - 113p.

4. Dyakonov V. Simulink 4. Special Handbook. - St. Petersburg: Peter, 2002. - 518 p.

5. Dyakonov V., Kruglov V. Mathematical extension packages MatLAB. Special guide. - St. Petersburg: Peter, 2001. - 475s.

6. Krasnoproshina A. A., Repnikova N. B., Ilchenko A. A. Modern Analysis control systems using MATLAB, Simulink, Control System: Tutorial. - K .: "Korniychuk", 1999. - 144 p.

7. Lazarev Yu. F. Cobs of programming in the MatLAB environment: Uch. allowance. - K .: "Korniychuk", 1999. - 160s.

8. Lazarev Yu. MatLAB 5.x. - K .: "Irina" (BHV), 2000. - 384 p.

9. V. S. Medvedev and V. G. Potemkin, Control System Toolbox. MatLAB 5 for students. - G.: "DIALOGUE-MEPhI", 1999. - 287 p.

10. Potemkin V. G. MatLAB 5 for students: Ref. allowance. - M.: "DIALOGUE-MEPhI", 1998. - 314 p.

1. Lesson 23. Introducing packages MATLAB extensions

Lesson number 23.

Introduction to MATLAB extension packages

    Listing extension packages

    Simulinc for Windows

    Package symbolic mathematics

    Math Packages

    Packages for analysis and synthesis of control systems

    System identification packages

    Additional features of the Simulinc package

    Signal and Image Processing Packages

    Other packages application programs

In this lesson, we will briefly get acquainted with the main means of professional expansion of the system and its adaptation to the solution of certain classes of mathematical and scientific and technical problems - with the extension packages of the MATLAB system. Undoubtedly, at least part of these packages should be devoted to a separate training course or guide, perhaps more than one. For most of these extensions, separate books have been published abroad, and the volume of documentation for them amounts to hundreds of megabytes. Unfortunately, the scope of this book allows only a brief walk through the expansion packs to give the reader an idea of ​​where the system is heading.

2. Listing extension packages

Listing extension packages

The complete composition of the MATLAB 6.0 system contains a number of components, the name, version number and creation date of which can be displayed with the ver command:

MATLAB Version 6.0.0.88 (R12) on PCWIN MATLAB License Number: 0

MATLAB Toolbox

Version 6.0

06-0ct-2000

Version 4.0

Version 4.0

04-0ct-2000

Stateflow Coder

Version 4.0

04-0ct-2000

Real-Time Workshop

Version 4.0

COMA Reference Blockset

Version 1.0.2

Communication Blockset

Version 2.0

Communication Toolbox

Version 2.0

Control System Toolbox

Version 5.0

DSP Blockset

Version 4.0

Data Acquisition Toolbox

Version 2.0

05-0ct-2000

Database Toolbox

Version 2.1

Datafeed Toolbox

Version 1.2

Dials & Gauges Blockset

Version 1.1

Filter Design Toolbox

Version 2.0

Financial Derivatives Toolbox

Version 1.0

Financial Time Series Toolbox

Version 1.0

Financial Toolbox

Version 2.1.2

Fixed Point Blockset

Version 3.0

Fuzzy Logic Toolbox

Version 2.1

GARCH Toolbox

Version 1.0

Image Processing Toolbox

Version 2.2.2

Instrument Control Toolbox

Version 1.0

LMI Control Toolbox

Version 1.0.6

MATLAB Compiler

Version 2.1

MATLAB Report Generator

Version 1.1

Mapping Toolbox

Version 1.2


Version 1.0.5

Motorola DSP Developer's Kit

Version 1.1

Ol-Sep-2000

Mi-Analysis and Synthesis Toolbox

Version 3.0.5

Neural Network Toolbox

Version 4.0

Nonlinear Control Design Blockset

Version 1.1.4

Optimization Toolbox

Version 2.1

Partial Differential Equation Toolbox

Version 1.0.3

Power System Blockset

Version 2.1

Real-Time Workshop Ada Coder

Version 4.0

Real-Time Workshop Embedded Coder

Version 1.0

Requirements Management Interface

Version 1.0.1

Robust Control Toolbox

Version 2.0.7

SB2SL (converts SystemBuild to Simu

Version 2.1

Signal Processing Toolbox

Version 5.0

Simulink Accelerator

Version 1.0

Model Differentiation for Simulink and...

Version 1.0

Simulink Model Coverage Tool

Version 1.0

Simulink Report Generator

Version 1.1

Spline Toolbox

Version 3.0

Statistics Toolbox

Version 3.0

Symbolic Math Toolbox

Version 2.1.2


Version 5.0

Wavelet Toolbox

Version 2.0

Version 1.1

xPC Target Embedded Option

Version 1.1

Please note that almost all extension packages in MATLAB 6.0 are up to date and date back to 2000. Their description has been noticeably expanded, which in PDF format already occupies many more than tens of thousands of pages. Given below short description main expansion packs

3 Simulink for Windows

Simulink for Windows

The Simulink extension package is used for simulation modeling of models consisting of graphic blocks with specified properties (parameters). Model components, in turn, are graphic blocks and models that are contained in a number of libraries and can be transferred to the main window with the mouse and connected to each other by the necessary links. Models can include signal sources of various types, virtual recording devices, graphical animation tools. Double-clicking on a model block displays a window with a list of its parameters that the user can change. Running a simulation provides mathematical modeling of the constructed model with a clear visual representation of the results. The package is based on the construction of block diagrams by transferring blocks from the library of components to the editing window of the model created by the user. The model is then run for execution. On fig. 23.1 shows the process of modeling a simple system - a hydraulic cylinder. Control is carried out using virtual oscilloscopes - in fig. 23.1 shows the screens of two such oscilloscopes and the window of a simple model subsystem. It is possible to model complex systems consisting of many subsystems.

Simulink composes and solves the equations of state of the model and allows you to connect a variety of virtual measuring instruments to the desired points in it. The clarity of presentation of simulation results is striking. A number of examples of using the Simulink package have already been given in Lesson 4. The previous version of the package is described in sufficient detail in books. The main innovation is the processing of matrix signals. Added individual packages Simulink performance enhancements such as Simulink Accelerator for compiling model code, Simulink profiler for code analysis, etc.

Rice. 23.1. Example of Hydraulic Cylinder System Simulation Using Simulink Extension

1.gif

Image:

1b.gif

Image:

4. Real Time Windows Target and Workshop

Real Time Windows Target and Workshop

The powerful real-time simulation subsystem connected to Simulink (with additional hardware in the form of computer expansion boards), represented by the Real Time Windows Target and Workshop expansion packs, is a powerful tool for managing real objects and systems. In addition, these extensions allow you to create executable model codes. Rice. 4.21 in Lesson 4 shows an example of such a simulation for a system described by non-linear van der Pol differential equations. The advantage of such modeling is its mathematical and physical clarity. In Simulink model components, you can specify not only fixed parameters, but also mathematical relationships that describe the behavior of the models.

5. Report Generator for MATLAB and Simulink

Report Generator for MATLAB and Simulink

Report Generators - a tool introduced in MATLAB 5.3.1, provides information about the operation of the MATLAB system and the Simulink extension package. This tool is very useful when debugging complex computational algorithms or when modeling complex systems. Report generators are launched with the Report command. Reports can be presented as programs and edited.

Report generators can run commands and program fragments included in reports and allow you to control the behavior of complex calculations.

6. Neural Networks Toolbox

Neural Networks Toolbox

A package of applied programs containing tools for building neural networks based on the behavior of a mathematical analogue of a neuron. The package provides powerful support for the design, training, and simulation of many well-known network paradigms, from basic perceptron models to state-of-the-art associative and self-organizing networks. The package can be used to explore and apply neural networks to problems such as signal processing, nonlinear control, and financial modeling. The ability to generate portable C-code using Real Time Workshop is provided.

The package includes more than 15 known types networks and learning rules that allow the user to choose the most appropriate paradigm for a particular application or research problem. For each type of architecture and training rules, there are functions for initialization, training, adaptation, creation and simulation, demonstration, and an example network application.

For controlled networks, you can choose direct or recurrent architecture using a variety of learning rules and design methods such as perceptron, backpropagation, Levenberg backpropagation, radial basis networks, and recurrent networks. You can easily change any architecture, learning rules or transition functions, add new ones - and all this without writing a single line in C or FORTRAN. An example of using the package for letter image recognition was given in Lesson 4. A detailed description of the previous version of the package can be found in the book.

7. Fuzzy Logic Toolbox

Fuzzy Logic Toolbox

The Fuzzy Logic application package refers to the theory of fuzzy (fuzzy) sets. Support is provided for modern methods of fuzzy clustering and adaptive fuzzy neural networks. The graphical tools of the package allow you to interactively monitor the behavior of the system.

Key features of the package:

  • definition of variables, fuzzy rules and membership functions;
  • interactive viewing of fuzzy inference;
  • modern methods: adaptive fuzzy inference using neural networks, fuzzy clustering;
  • interactive dynamic simulation in Simulink;
  • portable C code generation with Real-Time Workshop.

This example clearly shows the differences in the behavior of the model with and without fuzzy logic.

8. Symbolic Math Toolbox

Symbolic Math Toolbox

A package of application programs that give the MATLAB system fundamentally new capabilities - the ability to solve problems in a symbolic (analytical) form, including the implementation of exact arithmetic of arbitrary bit depth. The package is based on the use of the symbolic mathematics core of one of the most powerful computer algebra systems - Maple V R4. Provides symbolic differentiation and integration, calculation of sums and products, expansion in Taylor and Maclaurin series, operations with power polynomials (polynomials), calculation of polynomial roots, analytical solution of nonlinear equations, various symbolic transformations, substitutions and much more. Has direct access commands to the Maple V kernel.

The package allows you to prepare procedures with the syntax of the programming language of the Maple V R4 system and install them in the MATLAB system. Unfortunately, in terms of the possibilities of symbolic mathematics, the package is much inferior to specialized systems computer algebra, such as the latest versions of Maple and Mathematica.

9. Packages of mathematical calculations

Math Packages

MATLAB includes many extension packages that enhance the mathematical capabilities of the system, increase the speed, efficiency, and accuracy of calculations.

10.NAG Foundation Toolbox

NAG Foundation Toolbox

One of the most powerful math function libraries created by The Numerical Algorithms Group, Ltd. The package contains hundreds of new features. The names of the functions and the syntax for calling them are borrowed from the well-known NAG Foundation Library. As a result, advanced NAG FORTRAN users can easily work with the NAG package in MATLAB. The NAG Foundation library provides its functions in the form of object codes and corresponding m-files to call them. The user can easily modify these MEX files at the source code level.

The package provides the following features:

    polynomial roots and modified Laguerre method;

    calculation of the sum of a series: discrete and Hermitian-discrete Fourier transform;

    ordinary differential equations: Adams and Runge-Kutta methods;

    partial differential equations;

    interpolation;

    calculation of eigenvalues ​​and vectors, singular numbers, support for complex and real matrices;

    approximation of curves and surfaces: polynomials, cubic splines, Chebyshev polynomials;

    minimization and maximization of functions: linear and quadratic programming, extrema of functions of several variables;

    decomposition of matrices;

    solution of systems of linear equations;

    linear equations (LAPACK);

    statistical calculations, including descriptive statistics and probability distributions;

    correlation and regression analysis: linear, multivariate and generalized linear models;

    multidimensional methods: principal components, orthogonal rotations;

    random number generation: normal distribution, Poisson, Weibull and Koschie distributions;

    nonparametric statistics: Friedman, Kruskal-Wallis, Mann-Whitney; О time series: one-dimensional and multivariate;

    approximations of special functions: integral exponent, gamma function, Bessel and Hankel functions.

Finally, this package allows the user to create FORTRAN programs that link dynamically with MATLAB.

11. Spline Toolbox

A package of applied programs for working with splines. Supports 1D, 2D, and multidimensional spline interpolation and approximation. Provides presentation and display of complex data and graphics support.

The package allows you to perform interpolation, approximation and transformation of splines from B-form to piecewise polynomial, interpolation by cubic splines and smoothing, performing operations on splines: calculating the derivative, integral and mapping.

The Spline package is equipped with the B-spline programs described in "A Practical Guide to Splines" by Carl Deboer, creator of splines and author of the Spline package. The package's features, combined with the MATLAB language and detailed user guide, make it easy to understand splines and apply them effectively to a variety of problems.

The package includes programs for working with the two most common forms of spline representation: B-form and piecewise polynomial form. The B-form is convenient at the stage of constructing splines, while the piecewise polynomial form is more efficient during permanent job with a spline. The package includes functions for creating, displaying, interpolating, fitting and processing splines in B-form and as polynomial segments.

12. Statistics Toolbox

Statistics Toolbox

A package of applied programs on statistics that dramatically expands the capabilities of the MATLAB system in the field of implementing statistical calculations and statistical data processing. It contains a very representative set of tools for generating random numbers, vectors, matrices and arrays with different distribution laws, as well as many statistical functions. It should be noted that the most common statistical functions are part of the core of the MATLAB system (including functions for generating random data with uniform and normal distribution). Key features of the package:

    descriptive statistics;

    probability distributions;

    parameter estimation and approximation;

    hypothesis testing;

    multiple regression;

    interactive stepwise regression;

    Monte Carlo simulation;

    approximation on intervals;

    statistical process control;

    experiment planning;

    response surface modeling;

    approximation of a nonlinear model;

    principal component analysis;

    statistical charts;

    graphical user interface.

The package includes 20 different probability distributions, including t (Student's), F, and Chi-square. Fitting, graphical display of distributions, and a way to calculate best fit are provided for all types of distributions. There are many interactive tools for dynamic visualization and data analysis. There are specialized interfaces for modeling the response surface, visualization of distributions, generation of random numbers and level lines.

13. Optimization Toolbox

Optimization Toolbox

A package of applied problems - for solving optimization problems and systems of nonlinear equations. Supports the main methods for optimizing the functions of a number of variables:

    unconditional optimization of nonlinear functions;

    least squares method and non-linear interpolation;

    solution of non-linear equations;

    linear programming;

    quadratic programming;

    conditional minimization of nonlinear functions;

    minimax method;

    multicriteria optimization.

A variety of examples demonstrate the effective use of package functions. With their help, you can also compare how the same problem is solved by different methods.

14. Partial Differential Equations Toolbox

Partial Differential Equations Toolbox

A very important software package containing many functions for solving systems of partial differential equations. Gives effective means for solving such systems of equations, including stiff ones. The package uses the finite element method. The commands and GUI of the package can be used to mathematical modeling partial differential equations applied to a wide class of engineering and scientific applications, including problems of resistance of materials, calculations of electromagnetic devices, problems of heat and mass transfer and diffusion. Key features of the package:

    a full-fledged graphical interface for processing partial differential equations of the second order;

    automatic and adaptive grid selection;

    setting boundary conditions: Dirichlet, Neumann and mixed;

    flexible problem statement using MATLAB syntax;

    fully automatic meshing and finite element size selection;

    nonlinear and adaptive design schemes;

    possibility of visualization of fields of various parameters and solution functions, demonstration of the adopted partition and animation effects.

The package intuitively follows the six steps of solving a PDE using the Finite Element Method. These steps and the corresponding modes of the package are: define geometry (draw mode), specify boundary conditions (boundary conditions mode), select coefficients defining the problem (PDE mode), finite element discretization (mesh mode), specify initial conditions, and solve equations (solution mode), post-processing of the solution (graph mode).

15. Packages for analysis and synthesis of control systems

Packages for analysis and synthesis of control systems

Control System Toolbox

The Control System package is intended for modeling, analysis and design of automatic control systems - both continuous and discrete. The package functions implement traditional transfer function methods and modern state-space methods. Frequency and time responses, zero and pole patterns can be quickly calculated and displayed on the screen. The package includes:

    a complete set of tools for the analysis of MIMO-systems (multiple inputs - multiple outputs) systems;

    temporal characteristics: transfer and transition functions, response to arbitrary action;

    frequency characteristics: diagrams of Bode, Nichols, Nyquist, etc.;

    feedback development;

    design of LQR/LQE controllers;

    characteristics of models: controllability, observability, lowering the order of models;

    support for latency systems.

Additional model building functions allow you to design more complex models. The time response can be calculated for a pulse input, a single step, or an arbitrary input signal. There are also functions for analyzing singular values.

An interactive environment for comparing the time and frequency response of systems provides the user with graphical controls for simultaneously displaying responses and switching between them. Various response characteristics can be calculated, such as ramp-up time and ramp-down time.

The Control System package contains tools for selecting feedback options. Among the traditional methods: the analysis of singular points, the determination of the gain and attenuation. Among modern methods: linear-quadratic regulation, etc. The Control System package includes a large number of algorithms for designing and analyzing control systems. In addition, it has a customizable environment and allows you to create your own m-files.

16. Nonlinear Control Design Toolbox

Nonlinear Control Design Toolbox

Nonlinear Control Design (NCD) Blockset implements a dynamic optimization method for designing control systems. This tool, designed for use with Simulink, automatically tunes system parameters based on user-defined timing constraints.

The package uses mouse drag and drop to change timing constraints directly on plots, allowing easy setting of variables and specifying uncertain parameters, provides interactive optimization, implements Monte Carlo simulation, supports SISO (one input, one output) and MIMO control system design , allows simulation of interference cancellation, tracking and other types of responses, supports repetitive parameter problems and control problems for systems with delay, allows selection between satisfied and unattainable constraints.

17 Robust Control Toolbox

Robust Control Toolbox

The Robust Control package includes tools for designing and analyzing multi-parameter stable control systems. These are systems with simulation errors, whose dynamics are not fully known or whose parameters may change during simulation. Powerful algorithms of the package allow you to perform complex calculations, taking into account changes in many parameters. Package features:

    synthesis of LQG controllers based on the minimization of the uniform and integral norms;

    multi-parameter frequency response;

    building a state space model;

    transformation of models based on singular numbers;

    lowering the order of the model;

    spectral factorization.

The Robust Control package is based on the functions package Control System while providing an advanced set of algorithms for designing control systems. The package provides a transition between modern control theory and practical applications. It has many features that implement modern methods for designing and analyzing multi-parameter robust controllers.

Manifestations of uncertainties that violate the stability of systems are diverse - noise and disturbances in signals, inaccuracy of the transfer function model, non-modeled nonlinear dynamics. The Robust Control package allows you to evaluate the multi-parameter stability boundary under various uncertainties. Among the methods used: the Perron algorithm, analysis of the features of transfer functions, etc.

The Robust Control package provides various methods for designing feedbacks, including: LQR, LQG, LQG/LTR, etc. The need to reduce the order of the model arises in several cases: lowering the order of an object, lowering the order of a controller, modeling large systems. A qualitative procedure for lowering the order of a model must be numerically stable. The procedures included in the Robust Control package successfully cope with this task.

18. Model Predictive Control Toolbox

Model Predictive Control Toolbox

The Model Predictive Control package contains a complete set of tools for implementing a predictive control strategy. This strategy was developed to solve practical problems of managing complex multi-channel processes in the presence of restrictions on state variables and control. Predictive control methods are used in the chemical industry and to control other continuous processes. The package provides:

    modeling, identification and diagnostics of systems;

    support for MISO (many inputs - one output), MIMO, transient responses, state-space models;

    system analysis;

    converting models into various forms of representation (state space, transfer functions);

    providing tutorials and demos.

The predictive approach to control problems uses an explicit linear dynamic model object to predict the impact of future changes in control variables on the behavior of the object. The optimization problem is formulated as a quadratic programming problem with constraints, which is solved anew at each simulation step. The package allows you to create and test controllers for both simple and complex objects.

The package contains more than fifty specialized functions for the design, analysis and simulation of dynamic systems using predictive control. It supports the following types of systems: pulsed, continuous and discrete in time, state space. processed different kinds disturbances. In addition, restrictions on input and output variables can be explicitly included in the model.

Simulation tools allow for tracking and stabilization. Analysis tools include the calculation of closed loop poles, frequency response, and other characteristics of the control system. To identify the model in the package, there are functions for interacting with the System Identification package. The package also includes two Simulink functions that allow you to test non-linear models.

19. mu - Analysis and Synthesis

(Mu)-Analysis and Synthesis

The p-Analysis and Synthesis package contains functions for designing robust control systems. The package uses uniform-norm optimization and singular parameter and. This package includes a graphical interface to simplify block operations during design optimal controllers. Package properties:

  • designing regulators that are optimal in the uniform and integral norm;
  • estimation of real and complex singular parameter mu;
  • D-K iterations for approximate mu-synthesis;

    graphical interface for closed loop response analysis;

    means of lowering the order of the model;

    direct linking of individual blocks of large systems.

The state space model can be created and analyzed based on system matrices. The package supports work with continuous and discrete models. The package has a full-fledged graphical interface, including: the ability to set the range of input data, a special window for editing properties D-K iterations And graphic representation frequency characteristics. Has functions for matrix addition, multiplication, various transformations and other operations on matrices. Provides the ability to downgrade models.

20. Stateflow

Stateflow is an event-driven systems modeling package based on finite automata theory. This package is intended to be used in conjunction with the Simulink Dynamic Systems Simulation package. In any Simulink model, you can insert a Stateflow diagram (or SF diagram) that will reflect the behavior of the components of the simulation object (or system). SF-chart is animated. By its highlighted blocks and connections, one can trace all the stages of the simulated system or device and make its work dependent on certain events. Rice. 23.6 illustrates the simulation of the behavior of the car in the event of an emergency on the road. Under the car model, you can see the SF diagram (more precisely, one frame of its work).

To create SF diagrams, the package has a convenient and simple editor, as well as user interface tools.

21. Quantitative Feedback Theory Toolbox

Quantitative Feedback Theory Toolbox

The package contains functions for creating robust (stable) systems with feedback. QFT (Quantitative Feedback Theory) is an engineering technique that uses the frequency representation of models to meet various quality requirements in the presence of uncertain object characteristics. The method is based on the observation that feedback is necessary in cases where some characteristics of the object are uncertain and/or unknown perturbations are applied to its input. Package features:

    evaluation of the frequency boundaries of the uncertainty inherent in feedback;

    graphical user interface that allows you to optimize the process of finding the required feedback parameters;

    functions for determining the influence of various blocks introduced into the model (multiplexers, adders, feedback loops) in the presence of uncertainties;

    support for modeling analog and digital feedback loops, cascades and multi-loop circuits;

    resolution of uncertainty in the parameters of the object using parametric and non-parametric models or a combination of these types of models.

Feedback theory is a natural continuation of the classical frequency approach to design. Its main goal is to design simple, low order, minimum bandwidth controllers that perform well in the presence of uncertainties.

The package allows you to calculate various options feedbacks, filters, to test controllers both in continuous and discrete space. It has a user-friendly graphical interface that allows you to create simple controllers that meet the requirements of the user.

QFT allows you to design controllers that meet different requirements despite changes in model parameters. The measured data can be directly used to design controllers, without the need to identify complex system responses.

22. LMI Control Toolbox

LMI Control Toolbox

The LMI (Linear Matrix Inequality) Control package provides an integrated environment for setting and solving linear programming problems. The package, originally intended for designing control systems, allows you to solve any linear programming problems in almost any field of activity where such problems arise. Key features of the package:

    solving problems of linear programming: problems of compatibility of constraints, minimization of linear goals in the presence of linear constraints, minimization of eigenvalues;

    study of linear programming problems;

    graphic editor of linear programming tasks;

    setting limits in symbolic form;

    multicriteria design of regulators;

    stability test: quadratic stability of linear systems, Lyapunov stability, Popov criterion test for non-linear systems.

The LMI Control package contains modern simplex algorithms for solving linear programming problems. Uses a structural representation of linear constraints, which increases efficiency and minimizes memory requirements. The package has specialized tools for analysis and design of control systems based on linear programming.

With the help of linear programming problem solvers, you can easily check the stability of dynamic systems and systems with non-linear components. Previously, this type of analysis was considered too complex to implement. The package even allows such a combination of criteria, which was previously considered too complicated and solvable only with the help of heuristic approaches.

The package is a powerful tool for solving convex optimization problems that arise in areas such as control, identification, filtering, structural design, graph theory, interpolation and linear algebra. The LMI Control package includes two types of graphical user interface: the Linear Programming Problem Editor (LMI Editor) and the Magshape interface.LMI Editor allows you to set limits in symbolic form, and Magshape provides the user with convenient tools for working with the package.

23. System identification packages

System identification packages

System Identification Toolbox

The System Identification package contains tools for creating mathematical models of dynamic systems based on observed input and output data. It has a flexible graphical interface to help organize data and create models. The identification methods included in the package are applicable to a wide range of problems, from designing control systems and signal processing to analyzing time series and vibration. The main properties of the package:

    simple and flexible interface;

    data pre-processing, including pre-filtering, removal of trends and biases; О choice of data range for analysis;

    response analysis in time and frequency domain;

    display of zeros and poles of the transfer function of the system;

    residual analysis when testing the model;

    construction of complex diagrams, such as the Nyquist diagram, etc.

The graphical interface simplifies data pre-processing as well as the interactive model identification process. It is also possible to work with the package in command mode and using the Simulink extension. The operations of loading and saving data, selecting a range, deleting offsets and trends are performed with minimal effort and are located in the main menu.

The presentation of data and identified models is organized graphically in such a way that the user can easily return to the previous step of work during interactive identification. For beginners, it is possible to view the next possible steps. Graphical tools allow the specialist to find any of the previously obtained models and evaluate its quality in comparison with other models.

Starting by measuring the output and input, you can create a parametric model of the system that describes its behavior in dynamics. The package supports all traditional model structures, including autoregression, Box-Jenkins structure, and others. It supports linear state-space models that can be defined in both discrete and continuous space. These models can include an arbitrary number of inputs and outputs. The package includes functions that can be used as test data for identified models. The identification of linear models is widely used in the design of control systems when it is required to create a model of an object. In signal processing problems, models can be used for adaptive signal processing. Identification methods are also successfully used for financial applications.

24. Frequency Domain System Identification Toolbox

Frequency Domain System Identification Toolbox

The Frequency Domain System Identification package provides specialized tools for identifying linear dynamic systems by their time or frequency response. Frequency methods are aimed at identifying continuous systems, which is a powerful addition to the more traditional discrete technique. The package methods can be applied to problems such as modeling electrical, mechanical, and acoustic systems. Package properties:

    periodic perturbations, crest factor, optimal spectrum, pseudorandom and discrete binary sequences;

    calculation of confidence intervals of amplitude and phase, zeros and poles;

    identification of continuous and discrete systems with unknown delay;

    model diagnostics, including modeling and calculation of residuals;

    converting models to the System Identification Toolbox format and vice versa.

Using the frequency approach, one can achieve best model in the frequency domain; avoid discretization errors; it is easy to isolate the constant component of the signal; significantly improve the signal-to-noise ratio. To obtain disturbing signals, the package provides functions for generating binary sequences, minimizing the magnitude of the peak and improving the spectral characteristics. The package provides identification of continuous and discrete linear static systems, automatic generation of input signals, as well as a graphical representation of zeros and poles of the transfer function of the resulting system. Functions for testing the model include calculating residuals, transfer functions, zeros and poles, running the model using test data.

25. Additional MATLAB Extension Packages

Additional MATLAB Extension Packages

Communication Toolbox

A package of applied programs for building and modeling various telecommunication devices: digital lines communication, modems, signal converters, etc. It has the richest set of models of various communication and telecommunications devices. Contains a number of interesting simulation examples communication means, for example, a v34 modem, a modulator to provide single-sideband modulation, etc.

26. Digital Signal Processing (DSP) Blockset

Digital Signal Processing (DSP) Blockset

Application software package for designing devices using processors digital processing signals. First of all, these are high-performance digital filters with a frequency response (AFC) specified or adapted to the signal parameters. Simulation and design results digital devices using this package can be used to build high-performance digital filters on modern microprocessors digital signal processing.

27 Fixed Point Blockset

Fixed Point Blockset

This special package is focused on modeling digital control systems and digital filters as part of the Simulink package. A special set of components allows you to quickly switch between fixed and floating point (point) calculations. You can specify 8-, 16-, or 32-bit word lengths. The package has a number of useful properties:

    use of unsigned or binary arithmetic;

    user selection of the position of the binary point;

    automatic setting of the position of the binary point;

    viewing the maximum and minimum ranges of the model signal;

    switching between fixed and floating point calculations;

    overflow correction and availability of key components for fixed-point operations; logical operators, one- and two-dimensional reference tables.

28. Packages for signal and image processing

Signal and Image Processing Packages

Signal Processing Toolbox

A powerful package for the analysis, modeling and design of devices for processing all kinds of signals, providing their filtering and many transformations.

The Signal Processing package provides extremely rich signal processing capabilities for today's scientific and technical applications. The package uses a variety of filtering techniques and the latest spectral analysis algorithms. The package contains modules for the development of linear systems and time series analysis. The package will be useful, in particular, in such areas as audio and video information processing, telecommunications, geophysics, control tasks in real mode time, economics, finance and medicine. The main properties of the package:

    modeling of signals and linear systems;

    design, analysis and implementation of digital and analog filters;

    fast Fourier transform, discrete cosine and other transformations;

    spectrum estimation and statistical signal processing;

    parametric processing of time series;

    generation of signals of various shapes.

The Signal Processing package is the perfect wrapper for signal analysis and processing. It uses field-proven algorithms selected for maximum efficiency and reliability. The package contains a wide range of algorithms for representing signals and linear models. This set allows the user to be flexible enough to create a signal processing script. The package includes algorithms for converting a model from one view to another.

The Signal Processing package includes a complete set of methods for creating digital filters with a variety of characteristics. It allows you to quickly design high- and low-pass filters, band pass and stop filters, multi-band filters, including Chebyshev, Yule-Walker, elliptical, and others.

The graphical interface allows you to design filters by specifying requirements for them in the drag and drop mode. The following new filter design methods are included in the package:

    a generalized Chebyshev method for designing filters with a non-linear phase response, complex coefficients, or arbitrary response. The algorithm was developed by Maclenan and Karam in 1995;

    constrained least squares allows the user to explicitly control the maximum error (smoothing);

    calculation method minimum order filter with a Kaiser window;

    a generalized Butterworth method for designing low-pass filters with the most uniform pass and attenuation bands.

Based on the optimal Fast Fourier Transform algorithm, Signal Processing has unrivaled performance for frequency analysis and spectral estimation. The package includes functions for computing the discrete Fourier transform, discrete cosine transform, Hilbert transform, and other transforms commonly used in analysis, coding, and filtering. The package implements such spectral analysis methods as the Welch method, the maximum entropy method, etc.

The new graphical interface allows you to view and visually evaluate the characteristics of signals, design and apply filters, perform spectral analysis, investigating the influence various methods and their parameters on the result. The graphical interface is particularly useful for visualizing time series, spectra, time and frequency responses, and zero and pole locations of system transfer functions.

The Signal Processing package is the basis for solving many other problems. For example, by combining it with the package image processing, 2D signals and images can be processed and analyzed. Together with the System Identification package, the Signal Processing package allows you to perform parametric modeling of systems in the time domain. In combination with the Neural Network and Fuzzy Logic packages, many tools can be created for data processing or classification extraction. The signal generation tool allows you to create pulse signals of various shapes.

29. Higher-Order Spectral Analysis Toolbox

Higher-Order Spectral Analysis Toolbox

The Higher-Order Spectral Analysis package contains special algorithms for signal analysis using higher order moments. The package provides ample opportunities for the analysis of non-Gaussian signals, as it contains algorithms, perhaps the most advanced methods for analyzing and processing signals. Key features of the package:

    evaluation of high-order spectra;

    traditional or parametric approach;

    amplitude and phase recovery;

    adaptive linear forecasting;

    harmonic recovery;

    delay estimation;

    block signal processing.

The Higher-Order Spectral Analysis package allows you to analyze signals corrupted by non-Gaussian noise and processes occurring in nonlinear systems. High order spectra, defined in terms of high order moments of the signal, contain additional information that cannot be obtained using only autocorrelation or power spectrum analysis of the signal. High-order spectra allow:

    suppress additive color Gaussian noise;

    identify non-minimum-phase signals;

    highlight the information due to the non-Gaussian nature of the noise;

    detect and analyze non-linear properties of signals.

Possible applications of high-order spectral analysis include acoustics, biomedicine, econometrics, seismology, oceanography, plasma physics, radar and locators. The core features of the package support high-order spectra, cross spectral estimation, linear prediction models, and lag estimation.

30. Image Processing Toolbox

Image Processing Toolbox

The Image Processing suite provides scientists, engineers and even artists with a wide range of tools for digital image processing and analysis. Closely linked to the MATLAB application development environment, the Image Processing Toolbox frees you from time-consuming coding and debugging of algorithms, allowing you to focus on solving the main scientific or practical problem. The main properties of the package:

    restoration and selection of image details;

    work with a selected area of ​​the image;

    image analysis;

    linear filtering;

    image conversion;

    geometric transformations;

    increase the contrast of important details;

    binary transformations;

    image processing and statistics;

    color transformations;

    palette change;

    converting image types.

The Image Processing package provides ample opportunities for creating and analyzing graphic images in the MATLAB environment. This package provides an extremely flexible interface for manipulating images, interactively designing graphical paintings, visualizing datasets, and annotating results for technical descriptions, reports and publications. Flexibility, combination of package algorithms with such a feature of MATLAB as a matrix-vector description make the package very well suited for solving almost any tasks in the development and presentation of graphics. Examples of using this package in the MATLAB system environment were given in Lesson 7. MATLAB includes specially designed procedures to improve efficiency graphic shell. In particular, the following features can be noted:

    interactive debugging when developing graphics;

    profiler to optimize the execution time of the algorithm;

    tools for building an interactive graphical user interface (GUI Builder) to speed up the development of GUI templates, allowing you to customize it for user tasks.

This package allows the user to spend significantly less time and effort on creating standard graphics and thus concentrate on the important details and features of the images.

MATLAB and the Image Processing package are maximally adapted for the development, implementation of new ideas and user methods. To do this, there is a set of interfaced packages aimed at solving all sorts of specific tasks and tasks in an unconventional setting.

The Image Processing package is currently used extensively by over 4,000 companies and universities around the world. At the same time, there is a very wide range of tasks that users solve using this package, such as space research, military development, astronomy, medicine, biology, robotics, materials science, genetics, etc.

31 Wavelet Toolbox

The Wavelet package provides the user with a complete set of programs for studying multidimensional non-stationary phenomena using wavelets (short wave packets). Relatively recently created methods of the Wavelet package extend the user's capabilities in those areas where the Fourier decomposition technique is usually used. The package can be useful for applications such as speech and audio signal processing, telecommunications, geophysics, finance and medicine. The main properties of the package:

    advanced graphical user interface and a set of commands for analysis, synthesis, filtering of signals and images;

    conversion of multidimensional continuous signals;

    discrete signal conversion;

    decomposition and analysis of signals and images;

    a wide range of basis functions, including correction of boundary effects;

    batch processing of signals and images;

    analysis of signal packets based on entropy;

    filtering with the ability to set hard and soft thresholds;

    optimal signal compression.

Using the package, you can analyze features that other signal analysis methods miss, i.e. trends, outliers, breaks in high-order derivatives. The package allows you to compress and filter signals without obvious losses, even in cases where you need to save both high and low frequency components of the signal. There are compression and filtering algorithms for batch processing signals. Compression programs allocate the minimum number of coefficients that represent the original information most accurately, which is very important for the subsequent stages of the compression system. The following wavelet basis sets are included in the package: Biorthogonal, Haar, Mexican Hat, Mayer, etc. You can also add your own bases to the package.

An extensive user manual explains how to work with package methods, with numerous examples and a full reference section.

32. Other application packages

Other application packages

Financial Toolbox

Quite relevant for our period of market reforms is a package of applied programs for financial and economic calculations. It contains many functions for calculating compound interest, bank deposit operations, calculating profits and much more. Unfortunately, due to numerous (although, in general, not very fundamental) differences in financial and economic formulas, its use in our conditions is not always reasonable - there are many domestic programs for such calculations, for example, Accounting 1C. But if you want to connect to the databases of financial news agencies - Bloom-berg, IDC through the Datafeed Toolbox MATLAB package, then, of course, be sure to use the financial MATLAB extension packages.

The Financial package is the basis for solving many financial problems in MATLAB, from simple calculations to full-scale distributed applications. The Financial package can be used to calculate interest rates and profits, analyze derivative income and deposits, and optimize an investment portfolio. Key features of the package:

    data processing;

    dispersion analysis of the effectiveness of the investment portfolio;

    time series analysis;

    calculation of profitability of securities and evaluation of rates;

    statistical analysis and market sensitivity analysis;

    calculation of annual income and calculation of cash flows;

    depreciation and depreciation methods.

Given the importance of the date of a particular financial transaction, the Financial package includes several functions for manipulating dates and times in various formats. The Financial package allows you to calculate prices and returns when investing in bonds. The user has the ability to set non-standard, including irregular and inconsistent with each other, schedules for debit and credit operations and the final settlement when repaying bills. Economic sensitivity functions can be calculated taking into account different maturities.

Algorithms of the Financial package for calculating cash flow indicators and other data reflected in financial accounts make it possible to calculate, in particular, interest rates on loans and credits, profitability ratios, credit receipts and final accruals, evaluate and predict the value of the investment portfolio, calculate depreciation indicators, etc. The package functions can be used taking into account positive and negative cash flows (cash-flow) (excess cash flows over payments or cash payments over receipts, respectively).

The Financial package contains algorithms that allow you to analyze the investment portfolio, dynamics and economic sensitivity factors. In particular, when determining the efficiency of investments, the functions of the package make it possible to form a portfolio that satisfies the classical problem of G. Markowitz. The user can combine the package's algorithms to calculate Sharpe ratios and rates of return. Analysis of dynamics and economic sensitivities allows the user to identify positions for straddle trades, hedging and fixed rate trades. The Financial package also provides extensive opportunities for the presentation and presentation of data and results in the form of graphs and charts traditional for the economic and financial fields of activity. Funds can be displayed in decimal, bank and percentage formats at the request of the user.

33. Mapping Toolbox

The Mapping package provides a graphical and command interface for analyzing geographic data, displaying maps, and accessing external geographic data sources. In addition, the package is suitable for working with many well-known atlases. All these tools, in combination with MATLAB, provide users with all the conditions for productive work with scientific geographical data. Key features of the package:

    visualization, processing and analysis of graphic and scientific data;

    more than 60 map projections (direct and inverse);

    design and display of vector, matrix and composite maps;

    graphical interface for building and processing maps and data;

    global and regional data atlases and interfacing with high resolution government data;

    geographic statistics and navigation functions;

    three-dimensional representation of maps with built-in highlighting and shading;

    converters for popular geographic data formats: DCW, TIGER, ETOP5.

The Mapping package includes over 60 of the most widely used projections, including Cylindrical, Pseudocylindrical, Conic, Polyconic and Pseudoconic, Azimuth and Pseudoazimuth. Front and rear projections are possible, as well as non-standard projection types specified by the user.

In the Mapping package card any variable or set of variables that reflect or assign a numerical value is called geographic point or area. The package allows you to work with vector, matrix and mixed data maps. A powerful graphical interface enables interactive map manipulation, such as the ability to move the pointer over an object and click on it to get information. MAPTOOL GUI is a complete development environment for map applications.

The most widely known atlases of the world, United States, astronomical atlases are included in the package. The geographic data structure simplifies the extraction and processing of data from atlases and maps. The digital chart of the world (DCW), TIGER, TBASE and ETOP5 formats geographic data structure and external geographic data interfacing features come together to provide a powerful and flexible tool for accessing current and future geographic databases. Careful analysis of geographic data often requires mathematical methods that work in a spherical coordinate system. The Mapping package provides a subset of geographic, statistical, and navigational functions for analyzing geographic data. The navigation features provide ample opportunity to perform movement tasks such as positioning and route planning.

34. Power System Blockset

Data Acquisition Toolbox and Instrument Control Toolbox

Data Acquisition Toolbox - an extension package related to the field of data acquisition through blocks connected to the internal bus of a computer, function generators, spectrum analyzers - in a word, instruments widely used for research purposes to obtain data. They are backed by an appropriate computing base. New block Instrument Control Toolbox allows you to connect instruments and devices with serial interface and with Public Channel and VXI interfaces.

36. Database toolbox and Virtual Reality Toolbox

Database toolbox and Virtual Reality Toolbox

The speed of the Database toolbox has been increased by more than 100 times, with the help of which information is exchanged with a number of database management systems via ODBC or JDBC drivers:

  • Access 95 or 97 Microsoft;

    Microsoft SQL Server 6.5 or 7.0;

    Sybase Adaptive Server 11;

    Sybase (formerly Watcom) SQL Server Anywhere 5.0;

    IBM DB2 Universal 5.0;

  • Computer Associates Ingres (all editions).

All data is pre-converted to a cell array in MATLAB 6.0. In MATLAB 6.1, you can also use an array of structures. The Visual Query Builder allows you to create arbitrarily complex queries in the SQL dialects of these databases, even without knowledge of SQL. Many heterogeneous databases can be opened in one session.

The Virtual Reality Toolbox package is available starting with MATLAB 6.1. Allows for 3D animation and animation, including Simulink models. Programming language - VRML - virtual reality modeling language (Virtual Reality Modeling Language). The animation can be viewed from any computer equipped with a VRML-enabled browser. Confirms that mathematics is the science of quantitative relationships and spatial forms of any real or virtual worlds.

37.Excel Link

Allows you to use Microsoft Excel 97 as the MATLAB I/O processor. To do this, just install the excllinkxla file supplied by Math Works as an add-in function in Excel. In Excel, you need to type Service > Add-Ins > Browse, select a file in \matlabrl2\toolbox\exlink directory and install it. Now, every time you start Excel, the MATLAB command window will appear, and the panel Excel controls will be supplemented with getmatrix, putmatrix, evalstring buttons. To close MATLAB from Excel, just type =MLC1ose() in any Excel cell. To open after executing this command, you must either click on one of the getmatrix, putmatrix, evalstring buttons, or type in Excel Tools> Macro>Run mat! abi ni t. By selecting a range of Excel cells with the mouse, you can click on getmatrix and type in the name MATLAB variable. The matrix will appear in Excel. Once you've populated a range of Excel cells with numbers, you can select the range, click on putmatrix, and enter a MATLAB variable name. The operation is thus intuitive. Unlike MATLAB, Excel Link is not case sensitive: I and i, J and j are equivalent.

Call demo examples of expansion packs.

Most developers have a hard time imagining both its syntax and features. The thing is that the language is directly related to a popular software product, the cost of which can reach amazing values. So, the main question is: is the Matlab language itself good? And can it be useful for you.

Usage

Let's start not with a standard digression into history and a 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 a graphic editor in which you can realize any of your ideas without having several years of experience and relevant education behind you. And once you have created a scheme of interaction between tools, you can get a high-quality script for repeated use.

MATLAB is just such an editor in the data world. The scope of its application is infinitely wide: IoT, finance, medicine, space, automation, robotics, wireless systems and many many others. In general, almost unlimited possibilities for collecting and visualizing data, as well as forecasting, but only if you can buy the appropriate package.

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

Language Features

The MATLAB language is a tool that ensures the interaction of an operator (often not even a programmer) with all available opportunities analysis, collection and presentation of data. It has the obvious pros and cons of a language that lives in a closed ecosystem.

Disadvantages:

    Slow and overloaded with operators, commands, functions, a language whose main goal is to improve visual perception.

    Highly focused. There is no more software platform where MATLAB would be useful.

    Expensive 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 - the price is decent.

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

Advantages:

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

    Huge opportunities. But this is rather the advantage of the whole 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 into a “fast” code in C, C++.

The target audience

Of course, not everyone needs MATLAB. Despite the widest scope, it is difficult to imagine that an ordinary application developer would need knowledge of this language. MATLAB is extremely useful in areas that require special reliability in data processing, such as autopilot systems in cars or aircraft on-board electronic systems.

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

Literature

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

Do you have experience with MATLAB? And which?

For those who want to become a programmer - .

Top Related Articles