University of California, Berkeley
Department of Mechanical Engineering
Fall Semester 2008
Instructors: M. Frenklach, R.
E7, Assignment 2
Assigned: Thursday, September 11 2008
Due: 12:00pm, Friday, September 19, 2008.
This assignment is an introduction to using arrays, which are the basic building blocks in
. The ability to represent and handle multiple items in single collections is one of
the main strengths of
and it is what makes code-writing very short. As in the
previous assignment, turn in the hard copy of your published file to the drop boxes in
Etcheverry 1109 and upload the soft copy of your script (the m-file) to Bspace. Do not
forget to name your m-file as lastname_firstname_SID_lab02.m
in this assignment:
linspace, length, sort,
find, upper, lower, double, char, rem, size, max, min,
plot, polyder, polyval, roots, conv, poly
, create the row vector
having 9 regularly spaced elements starting
with 16 and ending with 48. Then, using the colon notation and transpose, create the
having a regular spacing of 0.5, starting with 0.5 and ending with 4.5.
Do the following tasks by using the appropriate array operations.
Divide each element of
Add 1 to each element of
Take the third power of each element of
Divide all elements of
by the corresponding element in
(e.g. element by element
Find the number of elements of
Assign the 5
to a new variable
Create a row vector
which is composed of the 6
(e.g. the 1
is the 6
Using the function
, define the row vector
that contains the
Please refer to
help to learn how to use the functions introduced in this assignment.