CS112: Lab 1 :: Introduction to MATLAB
MATLAB desktop and interactive environment
Getting started:
On a Macintosh, start MATLAB by clicking on this icon:
How to find MATLAB on a Wellesley public computer:
- Macintosh:
- From the Go menu at the top of your screen, select Applications
- From within the Applications folder, select MATLAB_R2008b
- Now you can click on the MATLAB icon shown above
- PC:
- Click here for how to find MATLAB on a PC.
Important parts of your MATLAB screen:
- Command Window
(circled in red)
Where you type your commands
- Command History
(circled in green) Keeps a record of your commands
- Current Directory Window
(circled in blue) Allows access to current directory
- Workspace
(circled in magenta) Variables (more on this later) are tracked here
Download the lab1 folder from cs112d
First, we'll use Fetch to connect to the CS server using the cs112d account.
Make sure that SFTP is selected from the drop-down menu (outlined above in orange).
Directions for Fetch are here.
For documentation using WinSCP on a PC, click here.
The username is cs112d and the password was given in class. This is where you will find
files that you need for labs and assignments throughout the semester.
Download a copy of the lab1_programs folder from the cs112d directory
onto your desktop. Rename the folder to be yours, e.g. sohie_lab1_programs.
| OLD | NEW |
| |
:: Helpful hints ::
-
Resize your MATLAB window via the lower right corner
-
Restore your MATLAB window
If your MATLAB windows somehow change their appearance, you can always
restore your setup by selecting and
this will recover your old MATLAB window appearance (see below)
-
Reduce extra blank lines
By typing format compact into your Command Window
- Use the
arrow keys
Use the up-arrow key to 'yank' back previously typed commands in the Command Window. The left and right-arrow keys can help you edit within a line.
-
Recycle
content from Command History window
You can highlight and select content from the Command History window into your Command window
(faster and more accurate than re-typing!)
- Clear the command window
clc clears the command window
- Comments in your code
-
% indicates a comment. MATLAB ignores
everything after the % sign. For example:
%
CS112 Lab 1 is a comment. Note that comments in the
MATLAB editor appear green. -
Commenting out chunks of code while debugging
 Select code with your
mouse, then choose from the menus (and you can
uncomment code as well).
Let's work with MATLAB now:
Exercises
- MATLAB Practice
- Exploring MATLAB's help
Uploading your saved work
We'll use Fetch again, but this time you will access your own personal
account and password.
This time, login to Fetch using your username (the one you used when filling out the
account request form, probably the same username as your firstclass username).
- Browse through your account, finding the drop/assign# folders
- Learn how to delete a file from your account
- Upload your sohie_lab1_programs folder into your personal cs112 account
- When done uploading, be sure to delete your
sohie_lab1_programs folder from the desktop
(by putting it in the trash can) and then empty the trash (Finder--> Empty Trash).
- Exit out of MATLAB when done
|