Set up the DFT algorithm
조회 수: 21 (최근 30일)
이전 댓글 표시
I am confused about these two questions given for develop the DFT algorithm:
- Set up the continuous mathematical model of DFT,
- Set up the discrete mathematical model of DFT,
and was told to use the discrete mathematical model of DFT to experiment with the function y = Nsin(2pi20t) + 2/3Nsin(2pi35t) + 2Nsin(2pi45t), and represent the spectral graph in the range of 0 to 60 Hz (N = 50).
i believe the task was to rebuilt the DFT algorithm without using the fft() function. I'd appreciate any assistance from anyone.
댓글 수: 0
채택된 답변
Yash
2024년 6월 17일
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!
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!