MATLAB: How to extend the plot to draw negative values of the x-axis? Let’s say -4 to 0

dspgraph

y = [8 2 5 3];
Y = fft(y);
figure(1);
subplot(2,1,1)
plot(abs(Y)),title('Magnitude');
Currently it only plots the x-axis from 1-4

Best Answer

You would have to define a frequency (x-axis) vector going from -4 to +4 as well, and then use the fftshift function on your ‘Y’ (or fft) vector.