Introduction to Programming in MATLAB


Lecture 1: Variables, Scripts, and Operations

Danilo Šćepanović
IAP 2010

Course Layout
• Lectures
1: 2: 3: 4: 5:

Variables, Scripts and Operations Visualization and Programming Solving Equations, Fitting Images, Animations, Advanced Methods Optional: Symbolic Math, Simulink

Course Layout
• Problem Sets / Office Hours
One per day, should take about 3 hours to do Submit doc or pdf (include code, figures) No set office hours but available by email

• Requirements for passing
Attend all lectures Complete all problem sets (-, √, +)

• Prerequisites
Basic familiarity with programming Basic linear algebra, differential equations, and probability

(1) (2) (3) (4) (5) Getting Started Scripts Making Variables Manipulating Variables Basic Plotting

Getting Started
• To get MATLAB Student Version for yourself »
Use VPN client to enable off-campus access Note: MIT certificates are required

• Open up MATLAB for Windows
Through the START Menu

• On Athena » add matlab » matlab &

Current directory


Command Window

Command History

Courtesy of The MathWorks, Inc. Used with permission.

Making Folders
• Use folders to keep your programs organized
• To make a new folder, click the ‘Browse’ button next to ‘Current Directory’

• Click the ‘Make New Folder’ button, and change the name of the folder. Do NOT use spaces in folder names. In the MATLAB folder, make two new folders: IAPMATLAB\day1 • Highlight the folder you just made and click ‘OK’ • The current directory is now the folder you just created • To see programs outside the current directory, they should be in the Path. Use File-> Set Path to add folders to the path

• File Preferences
Allows you personalize your MATLAB experience

Courtesy of The MathWorks, Inc. Used with permission.

• MATLAB can be thought of as a...