When you first start MATLAB, you will see this window:
Subsection1.3.1MATLAB Command Window
The Command Window is the main window of Matlab. Commands are typed into this window and interpreted by MATLAB:
>>
is the command prompt, that is the place where you can enter commands for MATLAB to execute.
As soon as you hit ’enter’, the command you just typed is executed (well, mostly. It gets a bit more complicated once we get to programming but for but for now think of MATLAB as simply a fancy graphing calculator).
Try it out right now: type 3 + 5 and hit enter.
Several commands can be typed on a single line by separating them with commas (think ; in C…)
Try it out right now: type 3+5, 4+6 and hit enter.
Use the up (\(\uparrow\)) and down (\(\downarrow\)) arrows to reissue previous commands, without having to retype them.
Try it out ….
Continue long lines with ellipsis (…) - watch out for spaces!
Try it out: type 3+..., hit enter, type 5 and hit enter.
The semicolon (;) prevents the output of your command from being echoed to the command window. This may seem useless right now, but just trust me: you’ll need this later.
The percent symbol (%) indicates a comment, which will become useful when writing programs in MATLAB.
clc clears the command window.
Subsection1.3.2More Windows
The Command History window displays a log of statements that you ran in the current and previous MATLAB sessions, along with information as to when you ran that command. You can simply double click on a command in the history window and it’ll get executed again. Or you can drag it over to the command window (in case you want to make edits, for example.) A colored mark precedes each statement that generated an error.
The Workspace window shows you all of the variables and other objects that are in use during your current session. We haven’t used any variables yet, but as soon as we do you’ll see the value of this window. Whereas in C we had to use printf() statements to monitor the values of variables in your code, the Worskape window allows you to keep track of variables without any extra work required.
MATLAB comes with a huge Online Help ecosystem. To access this help system, simply click on the question mark.
Within the help system you can find lots of manuals on everything you can think of.
Activity1.1.
Go to the online help in MATLAB and try to search for an example named "teapot". If you find the example, try to open up the code in your MATLAB window. Can you even figure out how to run the code?
And finally, MATLAB comes with lots of demo code. Can you find a demo named “teapot”? If so, open up the code in your MATLAB windows. Can you even figure out how to run the code?