Trouble with FFT and plotting velocity data for frequency

8 vues (au cours des 30 derniers jours)
Chris
Chris le 19 Nov 2014
Commenté : Star Strider le 7 Mar 2019
Hi
I have recently completed an experiment to measure turbulence behind a cylinder ie a Van Karman street. A hotwire was used to gain data and the hotwire (placed downstream) was moved up and down to measure velocities at different vertical positions.
I have multiple sets of data at a specific sample rate and number of samples all for each position as the hotwire is moved. The number of samples being 1024 and sample rate 660. The velocity data was stored in a CSV file which I have coded to be read into an array by MATLAB.
My problem is, I am trying to get the FFT data for these files so that I can show how the frequency peaks vary by the position of the hotwire. I have written some code which produces the FFT but it simply does not look right and I am unsure which part is actually referring to my frequency.
Obviously a FFT produces an imaginary number too and I am getting minus values for magnitude plots which shouldn't be possible? I also get the warning "Warning: Imaginary parts of complex X and/or Y arguments ignored" so was just wondering if anyone can help me out with this one?
clear,clc
a=load('101024660allvels.csv');
%Sample rate
s=1024;
%Creates time data
t=0:1/s:1-1/s;
%Does the transform
b=abs(fft(a));
%Removes erroneous max values
b(1,:) = [0];
%plots
figure;
plot(t,b);
ylabel('Magnitude');
title('Graph for Position 0 Samples 1024, Sample Rate 660','FontSize',12)

Réponse acceptée

Star Strider
Star Strider le 19 Nov 2014
Modifié(e) : Star Strider le 19 Nov 2014
Your fft should be calculated as:
b=abs(fft(a)/length(a));
and your frequency vector (that I call ‘fv’ here):
fv = linspace(0, 1, length(b)/2+1)*s/2;
iv = 1:length(fv);
. . . CODE . . .
figure;
plot(fv,b(iv));
but otherwise I see no problems with your code.
Attach a representative sample (or all) of '101024660allvels.csv' (use the ‘paperclip’ or ‘staple’ icon) so we can experiment and see if there is anything that could be causing problems.
  4 commentaires
RAJA RAMA KRISHNAA B U
RAJA RAMA KRISHNAA B U le 7 Mar 2019
May i know why is that [d,s,r] initiated at first ?
Star Strider
Star Strider le 7 Mar 2019
They are the outputs of the xlsread function.

Connectez-vous pour commenter.

Plus de réponses (1)

Chris
Chris le 19 Nov 2014
I have modified the code and I get the attached image. I think this is correct and it gives me a peak frequency! Thank you very much!

Community Treasure Hunt

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

Start Hunting!

Translated by