Difference between $\tt fft$ and $\tt dftmtx$ in MATLAB I have the following MATLAB code:
audioFile= audioread('myFile');
%% Reshape according to the given distortion period
distortionPeriod = 512;
audioFile= length(audioFile) / distortionPeriod;
audioFile= reshape(audioFile, [newLength, distortionPeriod]);

I noticed the following difference:
 audioFileFft = fft(audioFile); % incorrect transform
 audioFileDftMat = audioFile * dftmtx(distortionPeriod); % correct transform

&gt;&gt; norm(audioFileFft - audioFileDftMat )

ans =

   1.2985e+03

Why this difference exist? I would expect that those two operation(fft, dftmtx) would give the same result, as mentioned by MATLAB dftmtx's documentation.
How can I use the fft and still get the same results I got using the dftmtx?
Your resulting audioFile in the line audioFile= length(audioFile) / distortionPeriod; is a single number and not a vector signal.
And for this reason your audioFileFft and audioFileDftMat are computed from the processing of that number and not your initial signal vector in audioFile; which is not your intention. However if that line is for newLength, and this variable is an integer (i.e. initial audioFile length is multiple of distortionPeriod, here 512) then you can do this
audioFileFft = fft(audioFile, distortionPeriod, 2);  
audioFileDftMat = audioFile*dftmtx(distortionPeriod);

And the resulting norm(audioFileFft - audioFileDftMat) should be very small.