I'm having a little trouble plotting the DFT of a signal in dB. I can get the picture up nicely when using the magnitude but when I try converting the magnitude to decibels it all goes south. I've been using this for help: http://dadorran.wordpress.com/2014/02/20/plotting-frequency-spectrum-using-matlab/
Here is the code I'm running: (y is the signal obtained from a .mat file and L is the length of the signal)
Y = fft(y); MAG = abs(Y); MAGshift = abs(fftshift(Y)); bin_vals = [0:L-1]; L2 = L/2; f = Fs*(bin_vals - L2)/L; figure(1); plot(f,MAGshift); axis([-1000 1000 0 45000]); grid on;
With this I managed to get this lovely picture:
But when I convert the magnitude to decibels with mag2db(MAG) or 10*log10(MAG) and plot it, it does not look anything like this.