# Samples per second in a row vector in Matlab?

I wrote two functions in MATLAB, function called half that removes every other element from an arbitrary length vector, creating a shorter vector made of only the odd-numbered elements of the original vector; and a MATLAB function double that creates a longer vector by adding an additional element between neighboring elements in the original vector (Each new element should equal the average of its neighboring elements).

If you sample a $100\textrm{ Hz}$ tone at $8000$ samples per second, and store the samples as a row vector, what will be the effect of half and double on the pitch and duration of the tone if the playback rate is identical to the sampling rate? In other words, what is the new pitch in Hertz, and duration in seconds of the new sample in each case?

• This reads a lot like homework. Can you explain why just trying and applying your intuition and DSP knowledge don't work for you? – Marcus Müller Oct 16 '16 at 17:10
• It's a pre-lab. I honestly tried searching google and got nothing, I searched "pitch" and "duration" of a signal. Nothing... I wrote the two functions already, and they work, I just don't know how to sample a 100 Hz tone with 8000 samples per second, it doesn't mention anything online. – Struggling Oct 16 '16 at 20:19
• I took a matlab course before, but don't have any knowledge of DSP so posting it here makes sense. – Struggling Oct 16 '16 at 20:20

• Duration is just the length of the signal. half makes the duration half, and double makes it double!
• Pitch is the auditory sensation of the frequency. If you double the length of a signal (given the rate of playback remains the rate of sampling) then it will sound like a lower frequency. Similarly, when you make it half, it will sound like a higher frequency.

The code you can use to hear it:

fs = 8000;  % sampling frequency
duration = 1; % seconds
f0=100; % frequency
t=0:1/fs:duration; %time axis
wave = 10*sin(2*pi*f0*t);
sound(wave,fs) % original tone
pause
half_wave = wave(1:2:end);
sound(half_wave,fs) % half duraton, double pitch
pause
double_wave = interp1(linspace(0,1,numel(wave)),wave ,linspace(0,1,numel(wave)*2-1));
sound(double_wave,fs) % double duration, half pitch