Does anyone have a algorithm for DFT without FFT function in matlab?

and second question is how can I make zero padding in this algorithm?

  • $\begingroup$ Regarding the first question: have you tried dftmtx()? $\endgroup$
    – applesoup
    Dec 13 '18 at 13:28
  • $\begingroup$ how can I make dft to sine with this function? $\endgroup$ Dec 13 '18 at 13:38
  • $\begingroup$ You have to multiply your signal vector with the DFT matrix that is obtained with dftmtx() to obtain the DFT of your signal. The result is of course identical to the FFT. An example is shown here. $\endgroup$
    – applesoup
    Dec 13 '18 at 14:00
  • $\begingroup$ OK, I understood. I will try it. Thanks for the help. But is there somewhere the algorithm of the FFT function? $\endgroup$ Dec 13 '18 at 14:04
  • $\begingroup$ Well, the FFT algorithm is described in many books, the corresponding Wikipedia article or, of course, in the famous paper by Cooley and Tukey. $\endgroup$
    – applesoup
    Dec 13 '18 at 16:50

As mentioned by the applesoup, you should try dftmtx(). However, if you want to write a code for generating the DFT matrix, here it is,

funtion dftmatrix = myDFTmtx(N)

    dftmatrix = [];
    for k = 0:N-1
        row = [];
        for n = 0:N-1
            row = [row exp(-j*2*pi*k*n/N)];
        dftmatrix = [dftmatrix; row];

The matrix returned by this function when multiplied with the time domain sequence or column vector, will return its DFT coefficients.

  • $\begingroup$ You can construct the DFT matrix with a single line in matlab, without any loop: take a look at this answer. $\endgroup$
    – Matt L.
    Dec 13 '18 at 15:22
  • $\begingroup$ @MattL. I don't think efficiency would be that much important for someone looking for DFT without FFT... ( I assume the statment "without any loop" implied inefficient) $\endgroup$
    – Fat32
    Dec 13 '18 at 15:44
  • $\begingroup$ @Fat32: efficiency, but also simplicity AND understanding of how matlab works (namely, with matrices). It's a different kind of thinking when programming, and I thought the author of the answer might be interested. Just additional info, nothing more than that ... $\endgroup$
    – Matt L.
    Dec 13 '18 at 15:52
  • $\begingroup$ @MattL. yes I fully agree on the proper, efficient, or most importantly elegand use of Matlab language... $\endgroup$
    – Fat32
    Dec 13 '18 at 16:04
  • $\begingroup$ @MattL. Thanks for the additional info, It really helped me. $\endgroup$ Dec 13 '18 at 16:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.