Lab Activity 5 - Answer Sheet


Name: ____________________________ NetID: _________________ Section#: ______


Name: ____________________________ NetID: _________________ Section#: ______


Name: ____________________________ NetID: _________________ Section#: _____


Each blank is worth 1/5 point (30 blanks) except where noted

Part 1: Global variables in Matlab
  (10 blanks)

  1.   Write the value that Matlab returns when you type the following at the command prompt:
        >> x
               x =
                          __________5___________________
        >> y
               y =
                          __________0___________________
        >> result
                result  =
                              ________Undefined function or variable 'result'. (or something equivalent to this)_________________

  1.   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__________________


  1.   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__________________

  1.   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___________________

Part 2: Problems finding roots using fzero

  (6 blanks)
  1. 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)

  2. 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.

  3.  Write the command to display the number of values the vector  flipvolts contains, (don't use size, that's for matrices)

    >> ________length(flipvolts)__________________________

  4. 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)

    Free Fall : Parachuting , with air resistance

  (11 blanks)
  1. Fill in the blanks to complete the code for the function named Derivatives_resistance .
     function  Dyv = Derivatives_resistance(t , yv)

               y = ________yv(1);_____________________________

               v = ________yv(2);_____________________________
               g = 9.8;

               ____m = 100;_____________________________________

               _____b = 10;_____________________________________

               Dyv = ______[ v  ;  (-g -(b/m)*v)];_2/5 points__(may use dot form of the operators and some versions of Matlab may require the  parenthesis)_______

  1. What is the terminal velocity( the velocity at t = 100)? (approximately; and the units are m/s) _The exact solution is -m*g/b = -98 (if g = 9.8) but from the plot any value  around __-100 __   is acceptable. From yv(end, 2) you get  __-97.99550916652719__.
  1. 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 Dxyz = Derivatives_xyz(t , xyz)
    x = xyz(1);
    y = xyz(2);
    z = xyz(3);
    Dxyz = [  ____10*(y-x)______; _____-y + 28*x - x*z_______ ; _______(-8/3)*z + x*y____________];



  1. TA's initials for Part 3: __________signature____3/5points____________________