function halfspec(x) %note that N must be even or this won't work. N = length(x); M = N/2 + 1; X = fft(x); P = abs(X).^2; P1 = P(1:M); plot(1:M,P1) title('Single-Sided Amplitude Spectrum') xlabel('freq number') ylabel('|P1(f)|^2') end