18 Double the speed of the audio clip

Imagine that the guitar player plays at twice the speed that they were playing at in the original clip. If the sampling rate was kept constant, then the audio data would consist of every second element of the original audio data.

Write a function named doubleSpeed that returns a new audio vector that is equal to removing every second element of the input audio vector. The function should satisfy all of the following requirements:

  1. in should be named doubleSpeed
  2. it should have one input variable named y which is an audio vector
  3. it should have one return variable named z. z is the vector obtained by removing elements at index 2, 4, 6, … of y
  4. it should have a help documentation comment

For example:

z = doubleSpeed([1 2 3 4 5 6 7])

should set z to [1 3 5 7].

Play the double speed version of the original audio clip like so:

z = doubleSpeed(y);
sound(z, 16000);

The double speed version should play in the half the time of the original clip and sound higher in pitch.