how to perform fft in matlab using a set of data from excel sheet
14 ビュー (過去 30 日間)
古いコメントを表示
karan hindocha
2017 年 3 月 11 日
コメント済み: ahmad syaiful md subri
2019 年 11 月 22 日
Fs=3800;
Ts=1/Fs;
t=0:Ts:1;
L=97;
Y=abs(fft(VarName1)); %varname1 is the filename of the excel sheet
P1=Y/L;
P2=P1(1:(L+1)/2);
P2(2:end-1)=2*P2(2:end-1);
f=Fs*(0:(L/2))/L;
plot(f,P2)
xlabel('frequency')
ylabel('magnitude of P1')
Is this correct?
0 件のコメント
採用された回答
Star Strider
2017 年 3 月 11 日
I doubt if your code would work.
Try mine:
[d,s] = xlsread(VarName1); % Data in ‘d’
Fs=3800; % Sampling Frequency
Ts=1/Fs; % Sampling Interval
Fn = Fs/2; % Nyquist Frequency
L = size(d,1); % Length Of Arrayt
t = linspace(0, 1, L); % Time Vector
FTd = fft(d)/L; % Complex Fourier Transform Of ‘d’
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Matching Index Vector (For ‘FTd’ Addressing)
figure(1)
plot(Fv, abs(FTd(Iv))*2)
xlabel('frequency')
ylabel('magnitude of P1')
NOTE — This is UNTESTED CODE. It should work, but may require modification.
3 件のコメント
Star Strider
2017 年 3 月 11 日
‘could you tell me if I could do fft on the same excel sheet with two columns of data simultaneously?’
Yes, you can. The fft (link) function operates column-wise in a matrix, so it will take the Fourier transforms of each column with the same call to it. The frequency and index vectors will be the same as well. They should work without modification with your matrix.
ahmad syaiful md subri
2019 年 11 月 22 日
dataset=xlsread('Group5.xlsx','Sheet1','A1:ALM1')
tstep=0.001;
N=1;
t = 0:0.001:1-0.001;
x=dataset;
X=fft(x);
n=size(x,2)/2;
spec=abs(x)/n;
freq=(0:499/2*n*tstep);
plot(freq,spec(1:500));
can somebody help me..error :
Error using plot
Vectors must be the same length.
Error in Untitled (line 11)
plot(freq,spec(1:500));
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!