DFT code in matlab with out using FFT function?

1 answer

Answer

1084030

2026-05-11 10:55

+ Follow

To implement the Discrete Fourier Transform (DFT) in MATLAB without using the FFT function, you can use nested loops to compute the DFT directly. The formula for DFT is given by ( X(k) = \sum_{n=0}^{N-1} x(n) e^{-2\pi i nk/N} ), where ( N ) is the length of the input signal ( x ). Here’s a simple implementation:

<code class="language-matlab">function X = myDFT(x)

N = length(x); X = zeros(1, N); for k = 1:N for n = 1:N X(k) = X(k) + x(n) * exp(-2 * pi * 1i * (k-1) * (n-1) / N); end end end

</code>

This code computes the DFT by iterating over each frequency component and summing the contributions from all time-domain samples.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.