function spectrm(x,fs)
% spectrm(x,fs))
% plots the magnitude spectrum for the signal x,
% (a row vector), assuming a sampling frequency fs
% (the name 'spectrum' conflicts, so I re-spelled it)
	L=4096;              % L must be a power of 2 for the
	while L<length(x)    % Fast Fourier Transform function
		L=2*L;           % to work properly
	end	
	f=(fs/L)*[0:L/2];
	xhat=fft(x,L);
	s=(1/fs)*abs(xhat(1:L/2+1));	
	plot(f,s,'r')        % Plot the magnitude xhat
	axis([0 fs/2 0 1.2*max(s)])
	title('spectrum')
    xlabel('frequency in Hertz')
    ylabel('magnitude of xhat')