Take a look at the MATLAB interface, including the Command window, workspace, folder view, and Command History.
- [Instructor] Let's get started by taking a quick look at the MATLAB interface. The most prominent window is here in the center. That's the command window. This is similar to other command line interfaces that you might be used to using from other IDEs. We can do things here like do one plus two and MATLAB will return the answer. It's three. We can type in functions like cosine of zero and MATLAB will return one. And we can also clear the screen with clc. On the right here we see the workspace. This is where MATLAB stores all the variables we've created in this session.
We can see that we've already got ans and the value of one. ans stand for answer and that's what MATLAB returns when we don't ask for a variable. So for instance when we typed cosine of zero, MATLAB assigned ans equals one. We can create our own variables. I'll type in myVar and I'll set it equal to three plus four. MATLAB says yup, myVar is equal to seven and we can see that now over here in the workspace. myVar with a value of seven and MATLAB also tells us the class which is double.
You can remove a variable from the workspace by right clicking on the variable and selecting Delete or hitting the Delete key. You can also do it from the command line by saying clear and then whichever variable you want to clear so I'll clear myVar. I mean you can see that gets removed from the workspace. You can also remove all the variables from the workspace by typing clear all. I'll go ahead and clear the screen again with clc. And we can see here on the left, we have our folder view. Our current folder has shown up here in the task bar and if this contained any more files or folders, they'd be shown over here in the current folder view.
You can always create new files if you want to by right clicking and selecting New File or New Folder amongst other things but we don't need to do that right now. One last thing MATLAB also creates a history of all the command that we've entered. We can get to this by going to Layout, Command History and we'll pick Docked for now. This shows our command history down here on the right. If you want to run any one of these commands again, you can double click it. You see MATLAB runs it automatically and our variable is created in the workspace. You can also click and drag a command into the command window and that allows you to edit it.
So we'll set myVar equal to ten instead. Just like many other IDEs you can also press the up arrow while you're in the command line interface and cycle through the commands you've used. I'll clear the screen one last time and we're ready to go.
- Creating MATLAB variables
- Working with matrix and scalar operations
- Using if statements and loops
- Creating functions
- Importing data
- Building basic plots and 3D plots
- Working with images
- Creating Simulink models