I created a signal with two sinusoidal components by specifying
$$ f(t) = \cos(2\pi*4t)*5\cos(2\pi*0.4t) $$
I expected with I used MatLab's fft function on this that signal that I would see a peak of amplitude $1$ at a position of 4Hz in the spectrum corresponding to the 'fast' signal which has frequency $4$, and a peak of amplitude $5$ at a position of 0.4Hz in the spectrum corresponding to the 'slow' signal which has frequency $0.4$.
In my code below, subplots 3 and 4 are the fft plots, 3 is the unshifted one, and 4 is the shifted one. As you can see from running the code, I do not get the results I expected!
It seems I have peaks at $4+0.4=4.4$ Hz and $4-0.4=3.6$ Hz, and although the scaling is off with the amplitude, both peaks are the same height.
I thought the Fourier Transform would pick up the oscillations at 4Hz and 0.4Hz individually, and display them with their correct (relative) amplitudes? What has gone wrong?
function FFT_4() clc clear all close all sigFreq = 4; f = @(t) cos(2*pi*sigFreq*t)*5.*cos(2*pi*0.1*sigFreq*t); %% Calculation for samFreq > 2*sigFreq: Higher resolution samFreq = 12; [t,S,omega,power,fshift,powershift] = CalcFFT(f, samFreq); plotSignalandFFTSignal(4,t,S,omega,power,fshift,powershift) end function [t,S,omega,power,omegashift,powershift] = CalcFFT(f, samFreq) t = 0:(1/samFreq):(10-1/samFreq); % time vector S = f(t); n = length(S); X = fft(S); Y = fftshift(X); omega = (0:n-1)*(samFreq/n); %frequency range power = abs(X).^2/n; %power omegashift = (-n/2:n/2-1)*(samFreq/n); % zero-centered frequency range powershift = abs(Y).^2/n; end function plotSignalandFFTSignal(figNum,t,S,f,power,fshift,powershift) figure(figNum) subplot(2,2,1); plot(t,S); % xlim([0,1]) subplot(2,2,2); plot(power) subplot(2,2,3); plot(f,power) subplot(2,2,4); plot(fshift,powershift) end