Use the following method for picking every nth element from a data vector, starting with the first element. This demonstrates the effects of excessive downsampling (Nyquist's theorem).
1. Define the period and the sampling frequency.
2. Create a signal vector.
3. Define an integer n which is smaller than the length of vector v.
4. Use vector indexing to extract every nth element of vector v.
5. Plot the original and downsampled traces.
◦ When the new sampling rate is too slow (infrequent), the signal can look very distorted (try n = 15), disappear entirely (only sampling the 0 points - try n = 16), or aliasing can occur, that is, the signal appears to be of an incorrect frequency (n = 28, shown), because there aren't enough samples to accurately represent the information in the signal.
◦ Sampling has consequences for any numerical algorithm which is approximating a result at discrete intervals, such as the fast fourier transform, or differential equation solvers.