Talk:Fft.R
From Organic Design wiki
Matlab example
Fs = 5000; % Sampling frequency [Hz] Ts = 20; % Length of sample [s] f = 2; % Frequency of signal [Hz] f2 = 2.7; t = linspace(0,Ts,Fs*Ts); % Time series [s] y = 1.3*sin(2*pi*f*t)+.5*sin(2*pi*f2*t+20*pi/180)+10*randn(size(t)); % the signal [V] figure(1); plot(t,y); grid; Fy = fft(y)/length(y)*2; f = Fs/2*linspace(0,2,length(Fy)); figure(2); subplot(2,1,1); plot(f,abs(Fy)); grid; xlim([1.9 2.8]); subplot(2,1,2); grid; plot(f,angle(Fy)*180/pi,'.'); xlim([1.9 2.8]); grid;