You are on page 1of 4

HCC MATH-240-J445

PGCC MAT-2430-XD01H

DUE: Wednesday, July 16

MATLAB #01

Summer 2014

Project #1 25 points
The MATLAB prompt is >>
Operators for real numbers are: + - * / and ^ for addition,
subtraction, multiplication, division, and raising to a power.
To inhibit output from a command end the line with a semicolon.
Values can be stored in variables: X=5 stores the value 5 in the
variable X.
To see more than the default 5 digits on numeric values type format
long
To return to 5 digits type format short
To leave MATLAB enter quit or click the X box, top right.
To define a vector such as u=<1,2,3> type u=[1,2,3]. In other
words, use square brackets to indicate a vector.
To find the dot product of two vectors, type dot(u,v)
To find the cross product of two vectors, type cross(u,v)
To define variables a, b, and c as a symbolic variable type syms a
b c
To define a matrix of elements cij where i is the row number and j
is the column number type [c11 c12 c13;c21 c22 c23;c31 c32 c33]
This can be done with symbolic variables i j and k in row 1 if they
are defined as symbolic.
Additional MATLAB files can be found at the following web site:
o http://www.math.umd.edu/~jec/matcomp/matcompmfiles/mfiles.html
To plot a line in a two-dimensional rectangular coordinate system,
type plot([x0 x1],[y0 y1])
To set the viewing window (similar to the TI WINDOW) type
axis([xmin xmax ymin ymax])
To turn the grid on type grid on
To plot a line in a 3-D coordinate system, type plot3([x0 x1] ,[y0
y1] ,[z0 z1])
To plot a line given its parametric equations
x x1 at , y y1 bt , z z1 ct type the following series of commands (pick
two different values for t1 and t2): x = [x1 + a*t1,x1 + a*t2] y
= [y1 + b*t1,y1 + b*t2] z = [z1 + c*t1,z1 + c*t2] plot3(x,y,z)
To set the viewing window for a 3-D plot type axis([xmin xmax ymin
ymax zmin zmax])
r
A plane has an equation of the form ax by cz d 0 where n a, b, c is
a vector normal to the plane. Select a point P0 ( x0 , y0 , z0 ) in the
plane. To graph the plane type p0=[x0 y0 z0] n=[a b c]
plane(p0,n)
321707075.doc

Page | 1

HCC MATH-240-J445

DUE: Wednesday, July 16

MATLAB #01

PGCC MAT-2430-XD01H

Summer 2014

The preceding list is intended to help you understand how to do your


first MATLAB project. It is not comprehensive, and you will likely
need to use the help command to complete the project.
DIRECTIONS: Use MATLAB to do each of the following. Show each step
of your work in MATLAB by using the copy and paste feature to a
document or by using a DIARY. Please make sure that you indicate
where each problem starts and where it stops!
r
1. Find the dot product of u 1, 4,3

r
and v 3, 0, 4

using the dot

command.
u=[1 4 3];%vector u
v=[-3 0 4];%vector v
dot_product=dot(u,v)
Matlab Response:
dot_product =
9

r
2. Find the cross product of u 1, 4,3

r
and v 3, 0, 4

using the

cross command.
u=[1 4 3];%vector u
v=[-3 0 4];%vector v
cross_product= cross(u,v)
Matlab Response:
cross_product=
16
-13

12

3. Use the command syms i j k to define i (hat), j (hat), and k


(hat). Use the det command and the symbols you defined to
r r
find v u in unit-vector form.
syms i j k
u=[i 4*j 3*k];%vector u
v=[-3*i 0*j 4*k];%vector v
dot_product= dot(v,u)
cross_product=cross(v,u)
321707075.doc

Page | 2

HCC MATH-240-J445

DUE: Wednesday, July 16

MATLAB #01

PGCC MAT-2430-XD01H

Summer 2014

Matlab response:
dot_product =
12*k*conj(k) - 3*i*conj(i)
cross_product =
[ -16*j*k, 13*i*k, -12*i*j]

r r ur
4. Find the triple product u g v w

r
r
where u 3, 4, 2 , v 0,1,1 , and

ur
w 8,1, 0 .
u=[-3 4 2];
v=[0 1 1];
w=[8 1 0];
%to find u.(v*w)
c_product=cross(v,w);
tripleproduct1=dot(u,c_product)
%to find u*(v*w)
tripleproduct2=cross(u,c_product)
matlab response:
tripleproduct1 =
19
tripleproduct2 =
-48

-26

-20

r
5. Graph the line parallel to the vector u 2, 3, 4

that passes

through the point P 1,3,1 .


6. Graph the plane passing through the point P0 0, 0, 0 with normal
r
n 1, 2,3 .
7. Write a summary paragraph describing what you learned from this
project.
321707075.doc

Page | 3

HCC MATH-240-J445
PGCC MAT-2430-XD01H

DUE: Wednesday, July 16

MATLAB #01

Summer 2014

Your project must show the MATLAB commands that you use to solve the
above problems. But, be sure that you do not just show the MATLAB
commands your printout/document must also include the answers.
Also, be sure that the MATLAB commands you show give you the correct
answer to the problem!

321707075.doc

Page | 4

You might also like