function [p,f] = plotFFT(x, samplingFrequency, color)
% function [p,f] = plotFFT(x, samplingFrequency, color)
%
% This function plot the spectrum of a vector, x, which is sampled at
% sampleingFrequency
%
% x: a vector
% samplingFrequency: 10Hz by default
% color, the color
%
% Xu Cui
% 2009/07/16

if(nargin < 2)
    samplingFrequency = 10;
end
if(nargin < 3)
    color = 'b';
end

N = length(x);

x = x - mean(x);
z = fft(x);
z = z(1:N/2+1);
p = (abs(z)).^2;


f = [0:N/2]/(N)*samplingFrequency;

plot(f,p, 'color', color);
xlabel('frequency, Hz')
ylabel('power')