Forums

Re: FFT amplitude and frequencies

Started by Jeff Brower April 16, 2007
Denilson-

> Hello, i'm doing this code to see the FFT of 4 signals, all sin
> waves, the only difference is they are at different frequencies. But
> i'm having some problems in the amplitude of the FFT, it seems that
> those that i'm having are not correct.
> It is supposed to be 0.5 for all of them, i think.

Before worrying about exact amplitude levels, it might help to clarify your objective. If your frequencies are 100,
300, 700, and 900 MHz, and your sampling rate is 1800 MHz, then you want to combine the sinewaves in the time domain
and see one magnitude plot from 0 to 900 MHz? Or you want 4 separate magnitude plots, each with sample rate = 2f, or
each with sample rate 1800 MHz?

Please clarify.

-Jeff

> And i'm not sure if the x-axe for frequencies is correct.
> Please, someone give me a help here.
>
> %frequencies
> f10e6; f200e6; f3p0e6; f40e6;
> fase=0;
>
> NP;
>
> %Sample Frequency
> f=lcm(lcm(f1,f2),lcm(f3,f4));
> Fs=2*f;
>
> w1=2*pi*f1; w2=2*pi*f2; w3=2*pi*f3; w4=2*pi*f4;
>
> Am=1;
>
> t=-N*(1/Fs):1/Fs:N*(1/Fs);
> L=length(t);
>
> %Signals
> s1=Am*sin(w1*t + fase); s2=Am*sin(w2*t + fase); s3=Am*sin(w3*t +
> fase); s4=Am*sin(w4*t + fase);
>
> %FFT
> F1t(s1)/N/2; F2t(s2)/N/2; F3t(s3)/N/2; F4t(s4)/N/2;
>
> figure
> %PLOTs of the sins
> subplot(221), plot(t,s1); grid on
> title('s1'),xlabel('Tempo'); ylabel('Amplitude');
> subplot(222), plot(t,s2); grid on
> title('s2'),xlabel('Tempo'); ylabel('Amplitude');
> subplot(223), plot(t,s3); grid on
> title('s3'),xlabel('Tempo'); ylabel('Amplitude');
> subplot(224), plot(t,s4); grid on
> title('s4'),xlabel('Tempo'); ylabel('Amplitude');
>
> p=(0:L-1)*Fs/L;
>
> figure
> %PLOTs of the FFTs
> plot(p, abs(F1), 'b', p, abs(F2), 'm', p, abs(F3), 'c', p, abs
> (F4), 'r');
> xlabel('Frequcia (Hz) ')
> ylabel('Amplitude')
> grid on;
> figure
> %STEMs dos FFTs
> subplot(221), stem(p,abs(F1)); grid on
> title('100 MHz'),xlabel('Frequcia (Hz)'); ylabel('Amplitude');
> subplot(222), stem(p,abs(F2)); grid on
> title('300 MHz'),xlabel('Frequcia (Hz)'); ylabel('Amplitude');
> subplot(223), stem(p,abs(F3)); grid on
> title('700 MHz'),xlabel('Frequcia (Hz)'); ylabel('Amplitude');
> subplot(224), stem(p,abs(F4)); grid on
> title('900 MHz'),xlabel('Frequcia (Hz)'); ylabel('Amplitude');