Hello. This section is all about high-level programming in MATLAB. This is the final step before you will be rewarded by learning how to use acquired knowledge on proxy systematically, and be able to design your own human-robot interface. We will use MATLAB, however, once you know in one, you can learn another language like Python, yourself quite easily. We will start by observing the MATLAB environment, which is similar to other high-level environments, offers extended features over the basic ID's used for embedded programming. MATLAB and similar languages like Python, is very powerful tool for computing and prototyping. It is easy to learn. It is an interpreted language, which means that it executes instructions directly and freely without previously compiling a program into machine language instructions. So you can type commands and immediately see the result. As usual with all programming languages, we'll start with variables. There are plenty of differences compared to compiled languages. First of all, you do not have to declare the variable. MATLAB will assign a type for you depending on the stuff that you're doing with it. All variables that has been used and are not cleared, appear in the workspace and are constantly located in the stack memory. There are plenty of other features: some of them are unique to MATLAB and some which are common to other interpreted languages are worth reading about. MATLAB is specifically designed to perform an operation with matrices and vectors which are assigned with square brackets where rows are separated by semicolons with those brackets. Numerical sequences can be assigned with colons, where the step size can also be defined and defaults to one. All major matrix operations are overloaded, which means you can use the multiplication symbol to perform a matrix multiplication or division symbol to perform matrix inversion. You can also perform element-wise operations by adding the dot in front of the sign. For example, a dot multiply b, will multiply each element of a, to a correspondingly located element in b. Element of a matrix can be accessed by location using round brackets, where row comes first and columns second. You can also create multidimensional matrices if you want to. One entire row or column of a matrix can be accessed by a colon sign instead of a position. Matrices can be collapsed into vectors using single column in brackets as well. One important thing to notice is contrary to most languages, numeration in MATLAB starts with one instead of zero. So if you need to access the first element of a vector, you write V1 instead of V0 in Arduino C, annoying I know. MATLAB has huge, and I mean huge number of built-in function, literally from all areas of mathematics and engineering. Ranging from a simple like mean to a very specific complex functions like DSX fun. The real trick to MATLAB is learning which functions exist and how to use them. If you want to perform some operation, just Google it. A function will exist. The standard syntax for all functions is this: You need to specify output variables, which will be stored in the workspace and pass input variables which either already exist, or created inside the function core. Here is the list of simple functions for you to start experimenting. You can store and load the variables and data using specific dot mat, format. You can utilize the environment built buttons or use it in the code employing save and load functions. You can also save and load comma separated text files using the commands DLM read and DLM write. Similar, you can employ IM read and IM write commands to read images into matrices and write matrices into image files. Apart from matrices, there are strings, cells, and structures. Each one is good for a specific reason, so worth reading in the additional material. There are a number of functions for conversion between those types in addition to usual numerical type conversion functions. To start programming MATLAB, you either type the command in the command window or start a new script. The file that has list of all commands which will be executed sequentially and has the extension, dot m. It is good practice to annotate the code using the commands, which start with the percent symbol. The code can also be divided into the cells with a double percent symbol separating the cells. All code in the cell can be executed by pressing Control Enter when you cursor is on the cell directly from the script file. This way, you can easily debug chunks of code without running everything, by testing the result in each cell. Obviously, like in any program language, you can use loops for and while. The syntax of those is on your screen. Operation is similar to the previous loops we have learned with a slightly different syntax and the fact that you do not have to declare the variables. Also general rule is to avoid those in the code, as in comparison to compiled languages, they are very slow. Consider using matrix operations or built-in functions instead. Conditional statements are also there,if else, with a specific set of logical operators, some of them operating structure wise to the entire matrix and some can operate element wise. There is also a switch case structure. In case you are checking for the set of possible values for the same variable, you can obviously create your own functions. Simplest ways to convert the existing script into a function by the following syntax, specifying input and output variables. Any comments that you write on the top of the function will also be read by MATLAB help hub routine, and correctly displayed. Unlike scripts, which can see all variables in the workspace, functions use their own private workspace. So be careful when assuming you have already got some structure in place. A function will not see it unless you pass it to the input. Similar, none of the variables declared in the function will be seen outside of it unless declared on the output. MATLAB has very powerful built-in debugging for scripts and functions. Potential errors are underlined in red. They are also highlighted by orange or red marks in the roaring bar. MATLAB will suggest solutions to these potential errors, but they are not always appropriate or correct. Despite this, MATLAB cannot detect all potential errors. So be careful. You could make use of those specific debugging mode. This is initiated by clicking in the left-hand bar by the line numbers. Your code will then only run to that line where a red dot will appear. This is called a breakpoint. Clicking on the breakpoint again, will remove it. A small green arrow will indicate current position within the code being executed. You can subsequently step through your code, one line at a time, which allows you to identify the location and source of errors. You can escape the debug mode by executing DB-Quit command or clicking on the appropriate button. See you in the next lecture.