MATLAB is widely used for numerical calculations (a special toolbox
allows one to also perform symbolic manipulations using the MAPLE
kernel) in the industry, and in classes like differential equations, linear
algebra, and many engineering classes, in particular at the junior and
In our class we will begin slowly, primarily for calculations where
past we used EXCEL. -- Often you may like to still use EXCEL for
planning, laying out your data tables or matrices -- and then do the
real calculations in MATLAB.
1. Saying hello to MATLAB:
Take a guided tour, play w/ demo, explore the interface and help features.
2. Plotting in MATLAB:
MATLAB is as honest as possible: It will only plot points, and connect
them if you tell it to do so.
Exercise: Overlay the plot of y=sin(x) (using a red line) and the plot of
y=1/(1+x^2) using blue circles (for the points) for x from -7 to 7 in
steps of Dx=0.2.
3. MATLAB knows essentially only one data structure: matrices -- but
is quite amazing what matrices may represent. Tables, pictures, polynomials,
vectors, systems of equations, and so on!
Matrices and linear maps are studied in great detail in linear algebra (MAT
242 and MAT 342). There are no major surprises on how to add and subtract
matrices, or multiply them by scalars.
However, the way matrices are "most naturally multiplied" comes as a surprise
for most novices.
Work through the assignments in the sheet multiplying
matrices. You may
want to refer to these data. As homework (for substantial bonus credit, due
date Friday 2/19) create some larger example with more realistic foods, and,
e.g. your team's real food choices. Use MATLAB to multiply the matrices,
and paste the results into WORD (or your favorite word processor).
Create matrices A, B, C of sizes 2 x 3, 2 x 3 and 3 x 2, respectively.
Try out A*B, A.*B, B.*A, A*C, C*A, A.*C -- can you see what is going on?
If not start with "simpler" matrices A,B,C (e.g. more A=[10,1,0;300,0,7000],
so that it easier to track where the numbers come from).
4. The most common use of matrices, and also the usual starting place
linear algebra class are systems of linear equations.
Example: Find a quadratic function y=x1+x2t+x3t2
whose graph passes through
the points (..,..), (..,..), (..,..).What are the unknowns? Find a system of three
linear equations that represent the information given by the data points. Use
MATLAB to solve this system.
Exercise: Let y1y2y3y4y5y6y7y8
the digits of your birthrate in the form
mmddyyyy. Find a function y=x1+x2t+x3t2+x4t3+x5t4+x6t5+x7t6+x8t7 that
"interpolates" (whose graph passes through) the points (1,y1),(2,y2),(3,y3),
(4,y4),(5,y5),(6,y6),(7,y7), and (8,y8).
Use an 8 x 8 matrix in MATLAB. Plot the points (e.g. red circles) and overlay
the graph of the interpolating polynomial (e.g. blue line).
Complete all unfinished work as homework (for substantial bonus credit,
due date Friday 2/19.)