LLP109 Coursework Part 2-2 MATLAB coding mini-project

Dr. xxxxxx

Institute for Digital Technologies Loughborough University London

2. Fourier Transform

14

Discrete Fourier Transform of Vector

– In Matlab

Y = fft(X) and X = ifft(Y) implement the Fourier transform (FT) and inverse Fourier transform, respectively.

• Y(f) = fft(x(t)), Y(f): the representation of x(t) in the frequency domain, where f = 0, 1*df, 2*df, 3*df, …

• x(t) = ifft(Y(f)) , x(t): the representation of Y(f) in the time domain, where t = 0, 1*dt, 2*dt, 3*dt, …

15

[Q] Fourier Transform

Fourier Transform (FT)

• Calculate the Fourier Transform of the swept sine function by using the given

Matlab DSP function, i.e. fft(sweptsin).

• Define a frequency array. (Hint: use the frequency resolution df), i.e. 0, 1*df,

2*df, 3*df,…

• Draw the graph of the Fourier Transform of the function with respect to

frequency. The result of the Fourier Transform might be complex numbers. Show graphs of the real and imaginary parts of the result on a single figure window.

- Plot the magnitudes of the audio signal in the frequency domain.
- Change ranges of the result Y and f

16

%Use a for loop

[Q] Fourier Transform

LLP109 Coursework Part 2-2 MATLAB coding mini-project

Increase your (FT) window size, and draw the results in the time and frequency domains at each iteration. Such as,

fft(your_input(1:win_size*1)) and then plot() fft(your_input(1:win_size*2)) and then plot() fft(your_input(1:win_size*3)) and then plot()

………………….. fft(your_input(1:win_size*n)) and then plot()

% Repeat it until the end of the whole swept sine signal(t)

% Observe and analyse the results and describe them in your report % Refer to the example on the next slide

% There are only very few deduct points for the mistakes in signal processing or maths. In contrast, brave and creative attempts will be

well appreciated.

17

end

LLP109 Coursework Part 2-2 MATLAB coding mini-project

Example of the implementation

% You can use a for loop

for i = from 1 to the end with the increment of the (fft) window size

• frequency response (at each i-th iteration) = fft( the portion of the input signal [from 1 to i times the window size] )

% Pay attention to the length of the portion N, fft(y, N)

- frequency resolution = 1/(time resolution*the length of the portion)
- f= from 0 to frequency resolution times the length with the increment

of the frequency resolution

% The data in the time domain must be real numbers, whereas in the frequency domain complex numbers.

• pause(delay_time);

% If you want to slow down the speed of iterations, % e.g., delay_time=0.3 (sec.)