Hi David!
I am unable to understand the meaning of "continuous mathematical model of DFT". The Discrete Fourier Transform (DFT) is inherently a discrete process, designed to analyze the frequency content of digital signals (discrete in time).
For the discrete model of DFT, you need to implement the equation shown below:
For the given function "y" and parameter values, you can refer to the code below:
% Parameters
N = 50; % Given N
fs = 100; % Sampling frequency, must be more than twice the highest frequency in the signal
T = 1/fs; % Sampling period
L = 1000; % Total number of samples
t = (0:L-1)*T; % Time vector
% Signal
y = N*sin(2*pi*20*t) + (2/3)*N*sin(2*pi*35*t) + 2*N*sin(2*pi*45*t);
% DFT Implementation
X = zeros(1, L); % Preallocate the DFT result array
for k = 1:L
for n = 1:L
X(k) = X(k) + y(n) * exp(-j*2*pi*(k-1)*(n-1)/L);
end
end
% Frequency vector
f = fs*(0:(L/2))/L;
% Plotting the spectral graph
magnitude = abs(X/L); % Magnitude of the DFT
magnitude = magnitude(1:L/2+1);
magnitude(2:end-1) = 2*magnitude(2:end-1); % Because we're using only half of the DFT output
figure;
plot(f, magnitude);
title('Spectral Graph of y');
xlabel('Frequency (Hz)');
ylabel('|Y(f)|');
xlim([0 60]); % Limiting frequency range to 0-60 Hz
As you can observe, the peaks are obtained at 20Hz, 35Hz and 45Hz which are the frequencies mentioned in the sine terms of our function "y". Also, the height of the peaks are in the ratio of the coefficient of the sine terms. Hence, the DFT obtained is correct.
I hope this helps!