How to plot the fft if we are having the data ?

10 vues (au cours des 30 derniers jours)
vimal kumar chawda le 9 Juil 2021
time=ans(:,1); % Time vector
data = ans(:,2);
Messdaten1=ans(:,2);
fs=1/1.000000000000000e-03;
N=size(Messdaten1);
% X=fft({Messdaten}*2/N;
%f=fs/(N)*(1:N)
hfp = fplot(Messdaten1);
xv = hfp.XData;
yv = hfp.YData;
X=fft(yv);
Error is Error using fft
Invalid data type. First argument must be double, single, int8, uint8, int16, uint16, int32, uint32, or
logical.
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Réponses (1)

Sulaymon Eshkabilov le 10 Juil 2021
Hi,
Here is a correct and complete code for fft calc and plot with your data given in .xls data file:
clearvars; clf;
time=D.Var1; % Time
X = D.Var2; % Data
Fs=1e3; % Sampling frequency, [Hz]
L = length(X);
N = 2^nextpow2(L);
Y = fft(X, N);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of S(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrox Hardware dans Help Center et File Exchange

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by