Join Patrick Royal for an in-depth discussion in this video Understanding the MATLAB interface, part of Up and Running with MATLAB.
Let's take a look into the MATLAB interface, when you first open MATLAB, you will see that the interface is divided into four windows. On the left, the current folder window is placed all the files relevant to MATLAB in the folder that you are in. This is where all of the functions and scripts you create will be stored. It is important to make sure you are in the correct folder, when you're running scripts and functions as MATLAB will consider the act of folder for the purpose of running functions. By default, MATLAB will set the active folder to a folder called MATLAB in your Documents folder. To change the active folder, use the file path, listed in the top address bar, and navigate just as you would on a normal file system. You can also click on the Browse button and select a new folder through the standard files system view.
In the middle of the screen is the command window. This area holds all of your input and output as you run various functions. As the example I'll type help and press Enter. This brings up a list of all relevant help topics that will appear in the command window. Whenever you run a script or a function any output will be displayed here. Technically the command window has all of the same functions as the Script Editor. So, it is possible to write programs directly on this line, in practice, though, you'll probably want something that you can save, edit, and run multiple times.
At any time, if the command window gets too cluttered for your liking, you can clear it by typing clc and pressing Enter, or by clicking on the dropdown arrow in the top right corner of the tile and choosing Clear Command Window. On the top right of the screen is the workspace tile. This contain the list of all active variables in your simulation. To change the information available about your variables, right-click by the columns and select which piece of information you want to display. You can test out the workspace by creating a variable now.
Back in the command window type X equals 3 and press Enter. Notice how the work space now displays the variable X with a value of 3 and indicates it is a 1 by 1 matrix, which is just a scalar. The work space displays all variables you used in a given MATLAB session regardless of which script or function they come from. So, after a while it can get cluttered with old data. To clean up the workspace, click on the drop down arrow in the top right of the tile and choose Clear Workspace. After you confirm, MATLAB will delete all existing variables. Finally, the bottom right of the screen displays the command history. This keeps a record of all commands you type along with the dates and times of each session.
This feature allows you to easily go back and see which commands you sent in the past. You can also copy and paste task commands to run them again without having to type them out. As with the work space, you can clear the command history by clicking on the drop down menu and choosing Clear Command History. Now, let's move on to the top bar where you'll be creating all of your content. Starting from the left, the first option on the home tab is to create a new script. This is a default option because choosing a new script simply gives you a blank canvas to work with. All of the other options for creating a new item, just take the script interface and add some preset formatting.
Clicking on the new drop down menu brings up a list of all the other types of files that you can create. I'll cover these in more detail in future videos. The last important button is Open. This will allow you to select a file that is not in your current folder. We will cover the variable and code options here in future videos. The environment tab can be used to change the relative position of the tiles in MATLAB and the default active folder. The resources tab can be used to access the online documentation for MATLAB. If you're ever confused about what a command does or how it can be used, the Resources tab is a good place to look for assistance.
That should be enough to get us started, next, let's take a look at the MATLAB language itself.
- Installing MATLAB
- Working with MATLAB variables
- Working with matrix and scalar operations
- Creating functions
- Understanding performance considerations
- Building basic plots
- Creating responsive programs
- Editing variables manually
- Working with the Statistics Toolbox