hi...
this file may be helpful...
Added after 7 minutes:
hi...
this file might be helpful...
%Discrete Fourier Transform using FFT
close all;
clear;
A=1; %amplitude
DC = 0; %dc coomponent
fx = 200; %frequency of x
in Hz
w=2*pi*fx; %angular frequency (radians per sec)
fs = 10000; %sampling frequency Hz
Ts = 1/fs; %sampling time
C = 3; %no of cycles of x[n] to sample
N=1:C*round(fs/fx); %max(N) is the number of samples
%Time Domain
x = DC + (A * cos(w*(N-1)*Ts));
figure(1);
stem(x);
title('x
: Time (Samples) on X-Axis');
xlabel('Time (Samples)');
ylabel('Amplitude');
figure(2);
plotindex = 0: (C/fx)/length(N): (C/fx);
plotindex = plotindex(2:max(N)+1);
stem(plotindex,x);
title('x
: Time (Seconds) on X-Axis');
xlabel('Time (Seconds)');
ylabel('Amplitude');
%Frequency Domain
X = abs(fftshift(fft(x)));
figure(3);
plotindex=0:1:149;
stem(plotindex,X);
title('X(k): Frequency (Samples) on X-Axis ');
xlabel('Frequency (Samples)');
ylabel('Magnitude (Absolute Value)');
figure(4);
plotindex = -pi:2*pi/length(N)
i;
plotindex = plotindex(1:max(N));
stem(plotindex, X);
title('X(k): Frequency (Radians) on X-Axis');
xlabel('Frequency (Radians) [-\pi to \pi; where \pi = 3.142]');
ylabel('Magnitude (Absolute Value)');
axis([-pi pi 0 80]);
figure(5);
plotindex = -fs/2:fs/length(N):fs/2;
plotindex = plotindex(1:max(N));
stem(plotindex, X);
title('X(k): Frequency (Hertz) on X-Axis');
xlabel('Frequency (Hertz)');
ylabel('Magnitude (Absolute Value)');
axis([-fs/2 fs/2 0 80]);
disp('s');