Lab week 3: Fourier series, transformation and discrete signals ================================================================ Assignment 1. ------------- Sympy is a nice library for symbolmanipulation in Python and has some resemblance with Mathematica. Unfortunately it contains a few errors but the following assignment is possible. .. code-block:: python from sympy.plotting import plot from sympy import symbols x = Symbols('x') plot(x, x**2, x**3, (x, -5, 5)) .. code-block:: python from sympy import * x = Symbol('x') solve(x**2 - 3, x) Please note that there is a difference between sympy.symbols and sympy.Symbol Solve the following with sympy: .. math:: \int_{-\infty}^{+\infty} sin(x^2) dx Assignment 2. ------------- And now a bit more serious work with Fourier series. In controlsystems it's interesting to see how a system behaves when we apply a certain input signal. Much used input signals are step (Heaviside), ramp (sawtooth) and pulse (dirac, this one can result in some problems with sympy by the way). Determine the Fourier response for those 3 signals using sympy and plot a few terms of the series for a short interval. Plot input AND output signal. The result should look like: .. figure:: images/sawtooth.png Assignment 3. ------------- Write a Python function which creates a sine of 100 Hz and returns the samples with timing. Recreate the timedomain signal by using a Sinc and plot both functions. Experiment with different samplesarate above and below the Shannon frequency and show what happens. Assigment 4. ------------ Do the same for the following function: .. math:: x(t) = sin(\omega t) + 5 sin (3\omega t) + 3 cos(7\omega t + 10) Show what happens with different samplefrequencies. Assignment 5. ------------- The next file `muziek_48kHz.wav `_ contains a short piece of music in wav format. Using the 'wave' library of Python you can extract several interesting fields of this file: .. code-block:: python wav_header_dtype = np.dtype([ ("chunk_id", (str, 4)), ("chunk_size", "`_ You will see that it is quite noisy. The file cotains samples of 16 samples and was sampled with 500 Hz. we are only interested in channel 1. Plot this channel and take care to have correct values on the axis. We can filter this signal using convolution from the numpy library using a window of 'ones': .. code-block:: python window = np.ones(int(window_size))/float(window_size) Plot the filtered signal with a different color and experiment with the window size. Start with 10 for instance.