I am trying to extract amplitude of specific frequency in Matlab FFT. Is it possible to use the
abs(mag)... But I do not know in which sample to look for
mag(245) should give me amplitude for the frequency of that sample...
How to extract that amplitude-magnitude for $120$ Hz using
I will add simple code:
Fs = 1000; % Sampling frequency T = 1/Fs; % Sample time L = 1000; % Length of signal t = (0:L-1)*T; % Time vector % Sum of a 50 Hz sinusoid and a 120 Hz sinusoid x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t); y = x + 2*randn(size(t)); % Sinusoids plus noise f=(0:L-1)*Fs/L; x=fft(y); mag=abs(x); mag(1)=0; plot(f(1:L/2),(2/L*mag(1:L/2))); title('Single-Sided Amplitude Spectrum of y(t)') xlabel('Frequency (Hz)') ylabel('|Y(f)|')