Borrar filtros
Borrar filtros

FFT for the given data to find the dominant frequency

87 visualizaciones (últimos 30 días)
Naveen K S
Naveen K S el 3 de Mayo de 2019
Comentada: Star Strider el 3 de Jun. de 2022
hello everyone,
I have a data file containing a variable called "Lift coefficient" collected over a period of 1.25 seconds with time steps of 1e-5. I am performing the FFT but i'm not getting the desirable result. I am using the following code. Please find the data file also. Thankyou in advance
x=Cl;
plot(t,x)
t=VarName1;
y=fft(x);
f = (0:length(y)-1)*(10000)/length(y);
plot(f,abs(y))

Respuesta aceptada

Star Strider
Star Strider el 3 de Mayo de 2019
Editada: Star Strider el 3 de Mayo de 2019
Try this:
[D,S] = xlsread('forcecoefficients1.xlsx');
t = D(:,1);
Cl = D(:,2);
Ts = mean(diff(t));
Fs = 1/Ts;
Fn = Fs/2;
L = numel(t);
Clm = Cl-mean(Cl); % Subtract Mean (Mean = 0 Hz)
FCl = fft(Clm)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
[pks,locs] = findpeaks(abs(FCl(Iv))*2, 'MinPeakHeight',0.01);
figure
plot(Fv, abs(FCl(Iv))*2)
grid
xlim([0 1E3])
text(Fv(locs), pks, sprintf('\\leftarrow Dominant Frequency = %.2f', Fv(locs)), 'HorizontalAlignment','left')
The dominant frequency appears to be 226.4.
EDIT —
Added plot image:
FFT for the given data to find the dominant frequency- 2019 05 03.png
  2 comentarios
Guanting SU
Guanting SU el 29 de Oct. de 2019
This is absoluately helpful!
Star Strider
Star Strider el 29 de Oct. de 2019
@Guanting SU — Thank you!

Iniciar sesión para comentar.

Más respuestas (2)

Image Analyst
Image Analyst el 3 de Mayo de 2019
Editada: Image Analyst el 3 de Mayo de 2019
Is this homework?
Here's a start.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
data = readtable('forcecoefficients1.xlsx');
t = data.x_Time;
x = data.Cl;
% Get rid of garbage first point.
x(1) = x(2);
subplot(2, 1, 1);
plot(t, x, 'b-')
title('x vs. t', 'FontSize', fontSize);
xlabel('t', 'FontSize', fontSize);
ylabel('x', 'FontSize', fontSize);
grid on;
y=fftshift(fft(x - mean(x)));
f = (0:length(y)-1)*(10000)/length(y);
subplot(2, 1, 2);
plot(abs(y), 'b-', 'LineWidth', 2)
grid on;
title('Spectral Power', 'FontSize', fontSize);
xlabel('frequency', 'FontSize', fontSize);
ylabel('Power', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
It looks like there are two main spectral ranges with power in them:
See the two spikes close to the origin? You might want to set xlim() to zoom in and see them. Be sure to properly set up the units for the frequency axis. Now, what frequencies do you see the two spikes at? I don't want to do everything for you since I strongly suspect this is your homework and I don't want to get you in trouble for copying.

Kaosar Soomro
Kaosar Soomro el 3 de Jun. de 2022
In you code above, what does [D,S] represent and what do the letters refer to? Also, What is Cl and Clm?
Thank you!
  1 comentario
Star Strider
Star Strider el 3 de Jun. de 2022
They are the outputs from the xlsread function. See the documentation on xlsread for details.
The ‘Cl’ variable is the signal and ‘Clm’ is the signal with the mean of the signal subtracted from it so the spectrum peaks are easier to see.

Iniciar sesión para comentar.

Categorías

Más información sobre Octave 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!

Translated by