How to plot the fft if we are having the data ?
4 次查看(过去 30 天)
显示 更早的评论
load('Lp_400_Bw5.mat')
xlsread('Messdaten');
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 个评论
回答(1 个)
Sulaymon Eshkabilov
2021-7-10
Hi,
Here is a correct and complete code for fft calc and plot with your data given in .xls data file:
clearvars; clf;
D=readtable('Messdaten.xls');
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!