MATLAB Answers

how can i get my code to produce FFT graph.

2 views (last 30 days)
morris konadu
morris konadu on 29 Jul 2019
Answered: Vimal Rathod on 1 Aug 2019
This is my code below but doesnt work
L = length(signal);
Y = fft(signal);
Y1 = abs(Y);
% onlys show one sided FFT so multiply by 2, divide by Fs to scale.
Py = (2*Y1(1:L/2) / Fs);
% create frequency vector to plot against
freq = Fs/L*(0:L/2-1);
% plot the figure
figure
plot(freq,Py);
title('Amplitude Spectral Density');
xlabel('Frequency Hz');
ylabel('Amplitude');
grid on;
end

  1 Comment

dpb
dpb on 29 Jul 2019
Please edit code to remove superfluous linefeeds and then select and use the "Code" button to format it...

Sign in to comment.

Answers (1)

Vimal Rathod
Vimal Rathod on 1 Aug 2019
The code which you have given works perfectly fine, I suspect that you are not passing an appropriate signal to the fft function.
For more information refer to the link:

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by