The University of Texas at Austin
Fall 2011  PGE 310: Formulation and Solution in Geosystems Engineering
Homework #5: Working with Functions – Review of If Statements and Loop Structures
Due Date:
Thursday October 6
th
2011
Do NOT forget to follow the guideline for submitting homework
(Attached to the end of this file)
1.
Function Structure
(by HAND)
In each of the following, write
I.
The first line (by hand) of the MATLAB function file that would do the assigned task.
II.
The command (by hand) to call the function file from the interactive mode.
a.
I)
A function called
Discount.m
that when sent
the future worth of your money
(FW),
the discount rate
(i) and
time (t)
,
the present worth of your money (PW)
is returned.
II) Call the function when your future worth is
1500,
the discount rate is 2% and the time is 24. Store the result in
a variable called
PresentWorth
.
b.
I) A function called
RandArray.m
that returns a random 3by4 array called
RandomArray
and a random scalar
called
rand3
without sending any input.
II) Call the function in a single line, and store returned array in
MyArra
and
MyScalar.
c.
I) A function called
countor.m
that plots two graphs of y
2
versus x and x
2
versus y, when sent vectors
x and y
.
II) Call the function for
x = 10:0.5:20
,
y =20:0.5:30
.
d.
I) A function called
Equilib.m
that when sent
the external forces
(F),
the support forces (S)
and
the momentums
(M),
summation
of forces and momentums are returned
in Fx, Fy and MTotal.
II) Call and have the function calculate the result for
F=[14,20,30], S=[43,12] and M=[50,1,12]
. Store the
outputs
in
SumX
,
SumY
and
MTotal
.
Note that for each section, you need to write only two lines:
“the first line of the function file”
and
“calling the
function for the given input values”
.
2.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '06
 Klaus
 Lefthandedness, player, function file

Click to edit the document details