problem in plotting fft for set of samples

1 vue (au cours des 30 derniers jours)
Sunil Kumar
Sunil Kumar le 9 Avr 2019
Hello,
i am trying to plot FFT samples vs freq.. bt not getting the exact peak at expected frequency.
i have attached the samples in excel sheet,..plz can some one help me and guide me to get peaks at expected frequency.
clear
N=3584;
n=0:3584
ts=.0002;
fs=1/ts
ts1=0.02
f=1/(N*ts);
t=[0:N-1]*ts;
g=input('enter the frequency required')
ref=3*sin(2*pi()*g*t)
figure
plot(t,ref),axis tight
fref=abs(fft(ref))
figure
plot(abs(fref))
axis tight
x=xlsread('41hz.xlsx')
figure
plot(x),grid on
axis tight
Xf=abs(fft(x));
f1=[0:N-1]*f
plot(f1,abs(Xf)),grid on
axis tight
n_2=ceil(N/2)
figure
plot(f1(1:n_2),abs(Xf(1:n_2))),grid on
  2 commentaires
madhan ravi
madhan ravi le 9 Avr 2019
Modifié(e) : madhan ravi le 9 Avr 2019
What value are you inputting for g?
Sunil Kumar
Sunil Kumar le 9 Avr 2019
50 hz

Connectez-vous pour commenter.

Réponse acceptée

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 10 Mai 2019
Here is the corrected code that computes fft and plots accordingly.
N=3584; g=50;
ts=.0002;
fs=1/ts;
t=[0:N-1]*ts;
L = numel(t); % Length of your signal
f = fs*(0:(L/2))/L; % Frequency values
ref=3*sin(2*pi()*g*t);
figure
plot(t,ref),axis tight, title('Time domain signal')
fref=abs(fft(ref));
figure
plot(f, abs(fref(1:N/2+1))); % plot f vs. spectrum magnitude
xlim([0, 100])
%% Working with your measured/sampled data
DATA = xlsread('DATA_ES.xlsx', 'Sheet2');
L = numel(DATA(:, 1)); % Length of the signal
figure
ts=.0002; fs=1/ts;
Xf=abs(fft(DATA(:,1))); % Assuming Column 1 contains frequency response data
f=fs*(0:(L/2))/L;
n_2=ceil(N/2);
plot(f,abs(Xf(1:n_2+1))),grid on
  2 commentaires
Sunil Kumar
Sunil Kumar le 13 Mai 2019
Thank you so much
Sulaymon Eshkabilov
Sulaymon Eshkabilov le 13 Mai 2019
You are most welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by