Fast Fourier Transform for csv file with multiple column
이전 댓글 표시
Hello,
I have a set of .csv files containing about 20,000 lines each. The first column is a time interval (10ms) and the second, third and forth columns are for X, Y, and Z axes data respectively.
After reading this set of data and plotting them in their time domain, I am trying to perform a Fast Fourier Transform for them and plotting them in a graph, and also to generate a new .csv file with the data that underwent fft.
I've been reading up some other post of fft but seems like that are some parameters such as frequency that I am unsure of how I can get them.
I'm not sure how I should go about solving this and hope that some of you may be able to help me with this issue.
I have attached my code below
{
folderSource= 'C:\Users\r-o-n\Desktop\DP2\Testing2\csvtest\Incoming';
folderDestination= 'C:\Users\r-o-n\Desktop\DP2\Testing2\csvtest\Incoming\';
csvFiles=dir(fullfile(folderSource,'*.csv'));
for k=1:length(csvFiles)
baseFileName=csvFiles(k).name;
fullFileName=fullfile(folderSource,baseFileName);
inData=csvread(fullFileName,1,0);
end
t=inData(:,1);
x=inData(:,2);
y=inData(:,3);
z=inData(:,4);
subplot(3,1,1);
plot(t,x,':');
title('X-Axis');
ylabel('X-Acceleration (mg)');
subplot(3,1,2);
plot(t,y,':');
title('Y-Axis');
ylabel('Y-Acceleration (mg)');
subplot(3,1,3);
plot(t,z,':');
title('Z-Axis');
ylabel('Z-Acceleration (mg)');
xlabel('Time (ms)');
%would like to perform FTT to the data (both X,Y and Z)
xdft = fft(inData(:,2));
}
Thanks in advance! :)
Best Regards, Ron
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!