Lab Activity 5 - Answer Sheet


Name: ____________________________ NetID: _________________ Section#: ______


Name: ____________________________ NetID: _________________ Section#: ______


Name: ____________________________ NetID: _________________ Section#: _____

Part 1: Global variables in Matlab

  1.   Write the value that Matlab returns when you type the following at the command prompt:
        >> x
               x =
                          _____________________________
        >> y
               y =
                          _____________________________
        >> result
                result  =
                              ___________________________

  1.   Write the value that Matlab returns when you type the following at the command prompt:
        >> result = dummy(-4)
             result =
                          _____________________________
        >> y = dummy(0)
               y =
                          _____________________________
        >> result
                result  =
                              ___________________________


  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 =
                          _____________________________
        >>  y = dummy(-4)
               y =
                          _____________________________
        >> x
                x  =
                              ___________________________

  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 =
                          _____________________________

Part 2: Discretization of sound

  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( _________ : _________ : __________);
    >> message = audioplayer(flipvolts,frequency);

    >> play(message)

  2. What is the mystery message that with enlighten mankind?

    _____________________________________________________________________________________________

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

    >> __________________________________

  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( (_______________________________)/peak , frequency);
    >> play(player)


Free Fall : Parachuting , with air resistance


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

               y = _____________________________________

               v = _____________________________________
               g = 9.8;

               _________________________________________

               __________________________________________

               Dyv = _______________________________________

  1. What is the terminal velocity( the velocity at t = 100)? (approximately; and the units are m/s) ____________________________
  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 = [  ___________________________; ________________________________ ; _____________________________________];



  1. TA's initials for Part 3: __________________________________