how to perform fft in matlab using a set of data from excel sheet
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
karan hindocha
el 11 de Mzo. de 2017
Comentada: ahmad syaiful md subri
el 22 de Nov. de 2019
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 comentarios
Respuesta aceptada
Star Strider
el 11 de Mzo. de 2017
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 comentarios
Star Strider
el 11 de Mzo. de 2017
‘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
el 22 de Nov. de 2019
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));
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!