16 Convert an index to time

It would also be useful to be able to compute the time given an index.

Write a function named index2time that converts an index to a time in seconds given a specified sampling frequency. The function should satisfy all of the following requirements:

  1. in should be named index2time
  2. it should have two input variables named index and fs. index is the index that the caller wants to convert to a time in seconds. fs is the sampling frequency of the audio signal.
  3. it should have one return variable named time. time is the time in seconds that corresponds to index
  4. it should have a help documentation comment (see this link for how to correctly document a MATLAB function)

For example, in the guitar riff data, which is sampled at 16000 Hz:

index2time(1, 16000) should return 0

index2time(2, 16000) should return 1 / 16000

index2time(3, 16000) should return 2 / 16000

index2time(10001, 16000) should return 0.625

Different sampling rates should produce different times:

index2time(1, 50) should return 0

index2time(2, 100) should return 0.01

index2time(3, 400) should return 0.005