Hey folks,
I've got a Matlab FFT problem. Basically all I'm trying to do is generate a sinusoidal wave which is 20Hz, and generate the FFT of it and display that in a plot.
I've done this:
and the results I'm getting are these:
Figure 1
Figure 2
What on earth is that thingy at 80Hz? And when I change fo to 30Hz, or 40Hz, the spike on the left in Figure 1 moves up to 30Hz and 40Hz respectively, no worries, but that spike on the right moves closer in.. What on earth is going on? I thought these frequency spikes were meant to be symmetrically distributed around the 0Hz point on the frequency axis.
Thanks guys, you rock
Andrew
I've got a Matlab FFT problem. Basically all I'm trying to do is generate a sinusoidal wave which is 20Hz, and generate the FFT of it and display that in a plot.
I've done this:
Rich (BB code):
clc;
clear;
% Generate Sinusoidal of 20Hz
fo = 20; %frequency of the sine wave
Fs = 100; %sampling rate
Ts = 1/Fs; %sampling time interval
t = 0:Ts:1-Ts; %sampling period (samples 1-100, from 0sec to 0.99sec)
y = sin(2*pi*fo*t); %the sine curve
N=length(y); %get the number of points
k=0:N-1; %create a vector from 0 to N-1
T=N/Fs; %get the frequency interval
freq=k/T; %create the frequency range
X=fft(y,N);
figure(1)
plot(t,y);
figure(2)
plot(freq,abs(X))
Figure 1

Figure 2

What on earth is that thingy at 80Hz? And when I change fo to 30Hz, or 40Hz, the spike on the left in Figure 1 moves up to 30Hz and 40Hz respectively, no worries, but that spike on the right moves closer in.. What on earth is going on? I thought these frequency spikes were meant to be symmetrically distributed around the 0Hz point on the frequency axis.
Thanks guys, you rock
Andrew
Last edited: