This lab introduces (or re-introduces) the MATLAB environment. We focus on making plots and developing a 'computational thinking' approach to the development and testing of MATLAB functions.
Download
At the end of lab, submit a word-processing document with the results of your work. Also submit the m-files you created to answer these problems.
Lecture/Demo:
- Class orientation
- Launch MATLAB
- Simple calculator exercises
- Save commands in an m-file
- Set up directory structure
- Add path to your private toolbox directory
- Calculation with vectors
- Create vectors from
linspace
,rand
, etc. - plot
- plot a simplified model of the response of a vehicle suspension: for . This shows the need for .* operator
- Create vectors from
- Copy or save plots in MS Word, LaTeX
Example: Roots of the Quadratic Equation
MATLAB Summary
In this lab, the following code and concepts were introduced
- Entering commands in the command window
- Setting-up directories for saving m-file functions, and pointing MATLAB to those directories
- MATLAB commands and concepts
- Creating function m-files to store command sequences
- creating a vector with
[ .. ]
notation '
for transpose.*
and./
for array operations- Plotting data with the
plot
command - Annotating plots with
xlabel
andylabel
- Copying plots into MS Word
- Saving plots with the
print
command
- Using a MS Word template for homework and MATLAB assignments