Fs = 150; % Sampling frequency
t = 0:1/Fs:1; % Time vector of 1 second
f = 5; % Create a cos wave of f Hz.
pha = 1/3*pi; 
x = cos(2*pi*t*f + pha);
nfft = 1024; % Length of FFT
% Take fft, padding with zeros so that length(X) is
%equal to nfft
X = fft(x,nfft);
% FFT is symmetric, throw away second half
X = X(1:nfft/2);
% Take the magnitude of fft of x
mx = abs(X);
% Frequency vector

f = (0:nfft/2-1)*Fs/nfft;
% Generate the plot, title and labels.
figure(1);
plot(t,x);
title('cos Wave Signal');
xlabel('Time (s)');

xlabel(' s' );
ylabel('Amplitude');
figure(2);
plot(f,mx);
title('Power Spectrum of a cos Wave');
xlabel('Frequency (Hz)');
ylabel('power');