I want to get FFT of a vibration signal that is rrecorded in csv file. Fortunately, the figure with the plot of the signal displays correct data. However, when I try to perform fft, the figure is empty. I do not know of it is because of my code, the signal (or csv), or the MATLAB settings. Could you please help me to solve the problem.
Here is the code:
data = readtable('scope_0.csv');
column2 = data.Var2;
figure;
plot(column2(1:2000));
fs = 40000;
l1 = length(column2);
fft_result = fft(column2, l1);
fft_abs = abs(fft_result);
t = 0:1/fs:2000/fs;
freq = 0 : (1/t(end)) : fs/2 - (1/t(end));
figure;
plot(freq, fft_abs(1:length(freq)));
And the figures:

댓글 수: 2

Simon Chan
Simon Chan 2023년 6월 10일
Could you restart MATLAB and try to run it again?
If it is still not successful, could you attach your data so that we can try to reproduce the same problem or not.
I have attached the file, thanks

댓글을 달려면 로그인하십시오.

 채택된 답변

Star Strider
Star Strider 2023년 6월 10일

1 개 추천

Perhaps:
data(isinf(data)) = NaN;
data = fillmissing(data, 'linear');
since there may be a NaN or Inf value in ‘data’ that is causing the problem.
It would help to have the ‘scope_0.csv’ file.

댓글 수: 4

Thanks, I attached the csv file
Here you go —
data = readmatrix('scope_0.csv')
data = 2002×3
NaN 1.0000 NaN NaN NaN NaN -0.0250 0.2801 NaN -0.0250 -0.1571 NaN -0.0249 -0.2727 NaN -0.0249 0.0489 NaN -0.0249 -0.0616 NaN -0.0249 0.0791 NaN -0.0249 0.5113 NaN -0.0248 -0.2526 NaN
data = readtable('scope_0.csv');
column2 = data.Var2;
column2(isinf(column2)) = NaN;
column2 = fillmissing(column2, 'linear'); % 'fillmissing'
figure;
plot(column2(1:2000));
fs = 40000;
l1 = length(column2);
fft_result = fft(column2-mean(column2))/l1; % <= CHANGED (Slightly)
fft_abs = abs(fft_result);
t = 0:1/fs:2000/fs;
freq = 0 : (1/t(end)) : fs/2 - (1/t(end));
figure;
plot(freq, fft_abs(1:length(freq)));
Do not use fillmissing on ‘data’ or much (possibly all) of the matrix disappears because of the third column.
.
thanks a lot!
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Vibration Analysis에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2023년 6월 10일

댓글:

2023년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by