kanokwat
Newbie level 4
my code is
Fs=5000
T=1/Fs
L=5000
t=[0:L-1]*T
exam1= 10*sin(2*pi*50*t)+5*sin(2*pi*100*t)+2*sin(2*pi*200*t)
figure(1)
plot(t(1:800),exam1(1:800))
title(' x(t)')
xlabel('time(s)')
ylabel('X')
% use FFTmethod
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(exam1,NFFT)/L;
f_f = Fs/2*linspace(0,1,NFFT/2);
figure(2) % Plot single-sided amplitude spectrum.
k_k = 2*abs(Y(1:NFFT/2));
figure(2)
bar(f_f(1:500),k_k(1:500))
title('Single-Sided Amplitude Spectrum of x(t)')
xlabel('Frequency (Hz)')
ylabel('|X(f)|')
now i want amplitude at 50,100 and 200 Hz
how can i do that???
Fs=5000
T=1/Fs
L=5000
t=[0:L-1]*T
exam1= 10*sin(2*pi*50*t)+5*sin(2*pi*100*t)+2*sin(2*pi*200*t)
figure(1)
plot(t(1:800),exam1(1:800))
title(' x(t)')
xlabel('time(s)')
ylabel('X')
% use FFTmethod
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(exam1,NFFT)/L;
f_f = Fs/2*linspace(0,1,NFFT/2);
figure(2) % Plot single-sided amplitude spectrum.
k_k = 2*abs(Y(1:NFFT/2));
figure(2)
bar(f_f(1:500),k_k(1:500))
title('Single-Sided Amplitude Spectrum of x(t)')
xlabel('Frequency (Hz)')
ylabel('|X(f)|')
now i want amplitude at 50,100 and 200 Hz
how can i do that???