Free MATLAB training is the name of one of the unique, complete and free collections of Artificial Intelligence Academy. You can see the list of free MATLAB training sessions in this link ( click ). In the first session of free training MATLAB, we want to provide you with MATLAB software environment ( MATLAB ) are met. In this post about MATLAB software environment, our goal is to introduce you to a number of important windows in MATLAB, such as the Workspace window, the Command Windowو window in MATLAB, the Command History window, and the Current Folder window. 


What you will learn in the introduction session with MATLAB software environment

MATLAB features and windows are many and varied. If we want to introduce all of them to you in this session, you will probably get nervous and delete MATLAB software forever! So trust us and let us introduce you to MATLAB software at least during the next sessions. The table of contents of this meeting includes:


Get started with MATLAB

If you do not have MATLAB software installed, install it and then open it. MATLAB software environment will be as follows:

As you can see in the window above, there are three windows by default. These windows include the Workspace window, the Command Window in MATLAB, and the Current Folder. By default, some windows, such as Command History, are not enabled. In this session, we will explain how to activate this window. Clicking on any of the windows will make the window’s header turn blue, indicating that the window is active. The preliminaries are enough and let’s go to the first MATLAB window…



Command Window in MATLAB


One of the most important MATLAB windows is the Command Window window in MATLAB. The Persian translation is Command Window, the command window. That is the window or environment in which we can write our command, command, or code. In the following, we will explain more about the Command Window in MATLAB. This window is shown in the image above with a red box. In this window, you will see a sign in the form <<. This symbol is called a prompt. You must type your code (MATLAB commands) in front of this symbol. The absence of this sign means that MATLAB is not ready to receive the order! After entering the commands by pressing the Enter key, you can see the result immediately in the same window.

For example, suppose you do not have access to a calculator and you want to use MATLAB to perform calculations! Yes, you heard right, MATLAB can do the job of a calculator! Just type your calculations in MATLAB and press Enter. For example, we want to know how many times the number 6 multiplies! Just type 6 * 7 in the Command Window and press Enter.




Or, for example, we want to define a variable whose value is equal to 12. In this case, it is enough to write x = 12 in MATLAB (in future sessions we will talk in detail about the definition of variables in MATLAB) :



In the same way, you can write your own commands in the Command Window window and see the result. Well, so far enough in the session to get acquainted with the MATLAB software environment with the Command Window window. Let’s go to the next window…



Workspace window in MATLAB

Another application window for MATLAB is the workspace window . This window shows all the variables we have defined in the Command Window. That is, all the variables we created earlier are displayed with their values ​​in this window. For example, the figure in Figure 5 shows that we have already defined two variables called ans and x. You may ask, where did ans come from? When we do a calculation in MATLAB (for example, here 7 * 6) and do not save it in any variable, MATLAB itself saves it in the variable ans . Because it is possible that you need that number, but you forgot to put it in a variable.

Let’s go back to our discussion! We said that the workspace window shows that we have already defined two variables called ans and x. So what is the use of this? To answer this question, double-click on one of the variables. You will see a window similar to the one below:



You will see a new window open. This window shows the type, dimensions and contents of the variable we clicked on. What good is a web site if it simply “blends in” with everything else out there? We are the first way. In the future, we will define large matrices that may not be displayed correctly in the Command Window window. In such cases, the value of the workspace window is determined. But the newly opened window, with a cellular structure like Microsoft Excel, makes any matrix of any size look beautiful.

Note: When the MATLAB software is closed, the contents of this window will be deleted. Later we will teach you how to save these variables so that you do not miss them.

We reached the middle of the introduction session with MATLAB software environment. How has it been so far? Do not forget to share your opinion with us in the comments. Do not be lazy 😉.



Command History window in MATLAB

As mentioned in the introduction, the Command History window in MATLAB is not enabled by default. First, we will examine how to activate this window, then we will explain its function. To activate this window, just click on the layout option (yellow box in the image). In the list that opens, click Command History. A new list will open. This list includes three options: pop-up, docked and closed. Select the docked option to make the window always visible. This will display the Command History as follows:




The Persian equivalent of Command History is command history. The Command History window shows you the history of commands you have already entered. Any command you have executed in the Command Window will be visible in this window. For example, so far we have entered only two commands that even wrote the date and time of entering these commands!

But what good is a Command History window in MATLAB? It’s simple, to reuse the previous commands I ‌ wrote, imagine you coded yesterday in MATLAB. You reopened MATLAB today and you are busy. In addition to today’s commands, the commands you wrote yesterday are also in the Command History window. There are even recipes from days and months ago! This means that when the MATLAB software is closed, the contents of the Command History window will not be deleted.

Trick By double-clicking on any command, that command will be executed in the Command Window.

Trick, This window is the Drag & Drop feature. That is, drag a command with the mouse and drop it in the Command Window environment.

The difference between the above two tricks is that in the second trick, you have to hit Enter yourself for MATLAB to execute your command. But the first trick is performed automatically by double-clicking.



Current Folder window in MATLAB




The Current Folder window in MATLAB shows the contents of the current folder. Let’s take a look at Current Folder in MATLAB and give you a general example of Current Folder. Open an Explorer window in Windows (as shown below). Look at the address field shown in the image below. This address indicates the path to the folder you are in. For example, the image below shows that we are in a folder called MATLAB from “D: \ workspace\ Blog \ MATLAB”.

Currently, we only see files and folders in this path; We can open, delete them. Naturally, at this time, we do not see or access any other files or folders in Windows. For example, we do not have access to the files in the Python folder in the path “D: \ workspace\ Blog \ Python”. We can only see them when we go to “D: \ workspace \ Blog \ Python” and enter the Python folder. So in short, we can only see the contents of the Current Folder in Windows. The same is true for MATLAB, where Current Folder in MATLAB shows which files you can work with. Simply put, which folder does MATLAB see the contents of?




The trick is naturally similar to Windows, in cases where the folder address in MATLAB needs to be changed. To do this, click on option 4 in the image above. This will open a new window through which you can select another folder.

There is another option trick in the form of option 3 in the image above. Clicking on it will take you one step back from the folder in which it is located. That is, if we are in the address “E: / codes / matlab”, with this option we will go to the address “E: / codes”. With options 1 and 2, we can also switch between the folders we opened earlier.

What is the use of Current Folder in MATLAB? It’s too early now, stay tuned for the next sessions…