function[F,Xplot]= fftplot(x,M,deltat,pro) % FFTPLOT calculates and plots a meaningful frequency domain % representation of a signal. % % usage: FFTPLOT(x,M,deltat,proportion), x=input signal, M=M point FFT, deltat=sampling % interval, proportion= ratio of fs to plot to. % if you want to plot 0 to fs/10, pro is equal to 10.. X=fft(x,M); X=deltat*X; % calculate the FFT deltaf=deltat^-1/M; % determine the sampling frequency upperbound=round(M/pro); % how far do we plot? kplot=[0:upperbound+1]; % lets plot a little further Xplot=X(1:upperbound+2); % matlab doesn't start counting at 0. F=deltaf*kplot; % convert to Hz plot(F,abs(Xplot)); xlabel('Frequency (Hz)'); grid; % plot. axis([0 deltat^-1/pro 0 max(abs(X))+0.1*max(abs(X))]); %trim.