Dff in matlab usuallu involves inbuilt function fft Don't need to code your own fft unless specifically required.
For example:
>> clear
>> N=250;
>> ts=.00125;
>> deltaf=1/(N*ts);
>> t=[0:N-1]*ts;
>> x=cos(2*pi*100*t)+cos(2*pi*500*t);
>> Xf=fft(x);
>> Xf_shift=fftshift(Xf);
>> plot([-N/2:N/2-1]*deltaf, abs(Xf_shift))
If this doesn't already make sense, let us start discussing the problem and Finish at earliest.
Cheers!!!