Name: ____________________________ NetID:
_________________ Section#: ______
Each problem in Part 1 is worth 1/2 point.
1. Using the built-in function fzero write the Matlab command(s) to find a root of the function
fzero('x.^7 - log(x).^4',5) ( ^ or .^)
or
fzero(@(x) x.^7 - log(x).^4,5) ( ^ or .^)
___________________________________________________
2. Using the built-in function fplot write the Matlab command to plot the function
y = x4 - ln4(x)
on the interval [1,2].
fplot('x.^4 - log(x).^4',[1,2]) ( ^ or .^)
or
fplot(@(x)x.^4 - log(x).^4,[1,2]) ( ^ or .^)
___________________________________________________
3. Using the built-in function quadl write the Matlab command to compute the definite integral of the function
![]()
on the interval [1, 5]. (Don't write the answer just the Matlab code that gives the answer.)
quadl('exp(-x.^4)+ 5*cos(sin(50*x))',1,5) must use .^ but either * or .*
__________________________________________________
4. Using the built-in function trapz write the Matlab command to compute the definite integral of the function
![]()
on the interval [1, 5] using 100 points. (Don't write the answer just the Matlab code that gives the answer.)
You may use multiple lines.
x = _____linspace(1,5,100)________
y = _________exp(-x.^4)+ 5*cos(sin(50*x))__________ must use .^
trapz(_____x____,____y____)
5. Complete the following Matlab code, by filling in the blanks, to plot the surface described by the equation,
z =
cos( sqrt(x2 + y2)) / sqrt(x2
+
y2)
over the interval [-10,10] x [-10,10] in the x-y plane.
x = linspace(-10,10,400);
y = x;
[XMAT, YMAT ] = meshgrid(x,y);
ZMAT = __ cos( sqrt(XMAT.^2 + YMAT.^2)) ./ sqrt(XMAT.^2 + YMAT.^2);____(must use ./ and .^)_
surf( XMAT , YMAT , ZMAT )
6. (Each blank worth 1/4 point) We want to model the motion of a free falling object using the first order ordinary differential equation: http://en.wikipedia.org/wiki/Free_fall

(see also Classical Mechanics: A Modern Perspective 2nd ed. Barger and Olsson p. 8) where the mass of the object m = 75 Kg ,the acceleration due to gravity g = 9.8 m/s2 and
![]()
and
drag coefficient CD = 0.51, http://en.wikipedia.org/wiki/Drag_coefficient
cross-sectional area of the object, perpendicular to air flow A = 1.1 m2 ,
air density ρ = 1 Kg/ m3 ,
We want to solve for the vertical velocity v (which is a function of t written v = v(t) ) using the Matlab ODE solver ode45. Assume that at time t = 0, v = 0
( v(0) = 0).
To solve this equation we would type,
>> [ t,v] = ode45(@vprime, [0,100] , 0);
But we first need to complete the function named vprime.
a) Complete the function vprime by filling in the blank below.
function dv = vprime(t,v)
m = 75;
CD = 0.51;
A = 1.1;
rho = 1;
g = 9.8;
dv = __________((.5*CD*A*rho)./m) .* v.^2 – g;__ or _0.00374.* v.^2 - 9.8 ____________may use * and ^ rather than .* and .^ respectively__
b) Using this model what is the terminal velocity ? ____-51.1819 meters/sec__or anything close to -50_______________
(Hint: try plot(t,v) or v(end) )
Each blank in Parts 2,3 and 4 are worth 1/4 point (24 blanks = 6 points total for the following sections).
(3 blanks)Write the value that Matlab returns when you type the following at the command prompt:
>> x
x =
__________5___________________
>> y
y =
__________1___________________
>> result
result =
________Undefined function or variable
'result'. (or something equivalent to this)_________________
(3 blanks)Write the value that Matlab returns when you type the following at the command prompt:
>> result = dummy(-4)
result =
___________0__________________
>> y = dummy(0)
y =
___________4__________________
>> result
result =
_________0__________________
(3 blanks)In the editor modify the code for the dummy function by adding the global command as shown below,
function result = dummy(parameter)
global x
x = 4;
result = x + parameter;
Write the value that Matlab returns when you type the following at
the command prompt:
>> global x
>> x
x =
__________5___________________
>> y = dummy(-4)
y =
__________0___________________
>> x
x =
_________4__________________
In the editor modify the code for the dummy function by removing the statement x =4; so that your function should now look like the following:
function result = dummy(parameter)
global x
result = x + parameter;
Write the value that Matlab returns when you type the following at
the command prompt:
>> x = 10;
>> y = dummy(-4)
y =
__________6___________________
(3 blanks)If the sound has been
recorded backwards then let's solve the problem of
understanding the mystery message. Specifically, the problem
is that if
volts = [v1 v2 v3 ... vn] then we actually want [ vn ... v3 v2
v1]. Fill in the blanks and then type in this command to
listen to the message.
>> flipvolts = volts( ____end_____
:
____-1_____ : ____1______);
>> message = audioplayer(flipvolts,frequency);
>> play(message)
(3 blanks)What is the mystery
message that with enlighten mankind?
________To get to the opposite side. I
give up._____(just the first part is acceptable
and/or something similar in words )___
Ok, this is only the answer to the most important question in
the universe but we don't know the question. Others have
postulated the answer is 42.
Write the command to display the number of values the vector flipvolts contains, (don't use size, that's for matrices)
>> ________length(flipvolts)__________________________
Fill in the blank below with the new vector which is the old sound + new sound. You should hear the echo effect.
>> player = audioplayer( (_____flipvolts+shifted__________________________)/peak
,
frequency);
>> play(player)
Fill in the blank to complete the code for the function named Derivatives_resistance .
dydv = ______ [v ; ((.5*CD*A*rho)./m) .*
v.^2 - g ];___(may use dot form of
the operators and some versions of Matlab may require the
parenthesis)_______
What is the time (in seconds approximately) when the object
hits the ground (y = 0) ? Hint: plot t versus y. Use grid on
command too.
t = _____99.15 or something around 100
sec ______________ (approx.)
What is the velocity ( meters/second approximately) when the
object hits the ground (y = 0)?
v = _____-52.38_______or
something close to -50_____________(approx.)
(Of course this is the same answer as in prelab 5 question 6b)
Increase A (area) in the function named Derivative_friction
so that the terminal velocity is about -10 meters/second.
Round answer to nearest integer value.
A = _______27 meters2_____or
any
integer from 23 thru 31. The actual answer is
27.436_______________
(3 blanks)Complete the function named xyzprime that will compute the derivatives of the three dependent variables x, y and z , by filling in the blanks.
function dxdydz = Derivatives_xyz(t , xyz)
x = xyz(1);
y = xyz(2);
z = xyz(3);
dxdydz = [ ____10*(y-x)______; _____-y + 28*x - x*z_______ ; _______(-8/3)*z + x*y____________];
The actual data points (x,y,z) are plotted using
A) squares
B) stars
C) circles
D) diamonds