필터 지우기
필터 지우기

how to plot time and frequency domain by using FFT from CSV file?

조회 수: 11 (최근 30일)
Shwe
Shwe 2024년 4월 10일
답변: Star Strider 2024년 4월 10일
Hi,
Hello,
I have a CSV file.How to plot time and frequency domain using Fast-Fourier Transform (FFT)?
I would be delighted to any help.

채택된 답변

Star Strider
Star Strider 2024년 4월 10일
Try this —
A = readmatrix('FILE060.CSV');
Asz = size(A)
Asz = 1x2
729 258
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
t = A(:,1);
s = A(:,2:end-1);
figure
plot(t, s)
grid
xlim([min(A(:,1)) max(A(:,1))])
xlabel('Time (Units)')
ylabel('Amplitude (Units)')
[FTs1, Fv] = FFT1(s,t);
figure
plot(Fv, abs(FTs1)*2)
grid
xlabel('Frequency (Units)')
ylabel('Magnitude (Units)')
xlim([0 0.1])
figure
tiledlayout(4,4)
for k = 1:16:size(FTs1,2)
nexttile
plot(Fv, abs(FTs1(:,k))*2)
grid
Ax = gca;
Ax.XMinorGrid = 'on';
Ax.YMinorGrid = 'on';
xlim([0 0.05])
title("Col "+k)
end
sgtitle('Fourier Transform Array (Subset)')
function [FTs1,Fv] = FFT1(s,t)
t = t(:);
L = numel(t);
if size(s,2) == L
s = s.';
end
Fs = 1/mean(diff(t));
Fn = Fs/2;
NFFT = 2^nextpow2(L);
FTs = fft((s - mean(s)) .* hann(L).*ones(1,size(s,2)), NFFT)/sum(hann(L));
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
FTs1 = FTs(Iv,:);
end
The complete set of 256 individual plots do not display well here, so I only plotted 16 of them individually. .
I created ‘FFT1’ for my own use, to make my life easier. Feel free to use it.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by