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

조회 수: 5 (최근 30일)
vimal kumar chawda
vimal kumar chawda 2021년 7월 9일
답변: Sulaymon Eshkabilov 2021년 7월 10일
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.

답변 (1개)

Sulaymon Eshkabilov
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)|')

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by