# FFT: Extracted spectrum depends on number of points sampled

I have a signal $a(t)$, this is how it looks when I plot it:

I am trying to extract the eigenfrequencies of this signal using FFT in MATLAB. I do it like this

Y=fft( a(1:3:end) );

Fs = 1/1.5;       % Sampling frequency
T = 1/Fs;         % Sampling period
L = dms(2);       % Length of signal
t = (0:L-1)*T;    % Time vector

P2 = abs(Y/L);
P1 = P2(1:floor(L/2)+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f, P1)


Now, it turns out that if I use Y=fft( a ), I only get frequencies close to 0 when I plot the spectrum: If I use Y=fft( a(1:3:end) ), then I get frequencies at 0 and nonzero frequencies: 1. Why do these nonzero frequencies not appear when I do the FFT on the full dataset, but only when I sample every 4th point?
2. Is the nonzero frequency actually contained in my dataset or is it an artifact?
• you should add the sampling frequency you use and how exactly you're plotting this. – Marcus Müller Oct 16 '16 at 18:42
• can you also add a zoomed in plot of your time domain signal? I really don't know what you're looking for in the spectrum at this point – Marcus Müller Oct 16 '16 at 18:47
• I added a zoom-in as well. I'm trying to extract the oscillation-frequencies of the signal – BillyJean Oct 16 '16 at 18:50
• can you zoom in more? – Marcus Müller Oct 16 '16 at 18:53
• uh-oh. you undersampled. See my answer's edit. – Marcus Müller Oct 16 '16 at 20:48

Well, yes, but that means you decimate your signal by a factor of 3, which on one hand will shift frequencies to $\frac13$ of their original frequency, but also will lead to aliasing. In other words: unless you know there's no signal above $f=\frac16f_\text{sample}$, you simply can't do that.
Now, if you just look at every third sample, which you do by doing a(1:3:end), then there's only ~1.333 samples per period. Nyquist demands that there's at least 2 samples per period. So, your second attempt aliases the signal from the $\frac15f_\text{sample/2}$ onto a different point in the spectrum, where it actually isn't. You damaged your signal by undersampling; you mustn't do that. It's not very clear to me how the idea to do that happened in the first place, but you should definitely read up on the Sampling Theorem.