MATLAB FFT。 难以理解频率和结果之间的关系

发布于 2024-07-07 20:05:19 字数 312 浏览 8 评论 0 原文

我们正在尝试分析圆柱体周围的流动,并且我们有一组从风洞实验中获得的 Cp 值。 最初,我们从 20 Hz 的采样频率开始,并尝试在 matlab 中使用 FFT 找到涡旋脱落的频率。 我们得到的频率约为 7 Hz。 接下来,我们做了同样的实验,但我们唯一改变的是采样频率——从 20 Hz 到 200 Hz。 我们得到的涡旋脱落频率约为 70 Hz(这是图中峰值所在的位置)。 无论我们输入多少 Cp 数据,图表都不会改变。 峰值唯一不同的时间是当我们改变采样频率时。 看起来涡旋脱落频率的增加与采样频率成正比,这似乎根本没有意义。 任何有关建立采样频率和涡流脱落频率之间关系的帮助将不胜感激。

We're trying to analyse flow around circular cylinder and we have a set of Cp values that we got from wind tunnel experiment. Initially, we started off with a sample frequency of 20 Hz and tried to find the frequency of vortex shedding using FFT in matlab. We got a frequency of around 7 Hz. Next, we did the same experiment, but the only thing we changed was the sampling frequency- from 20 Hz to 200 Hz. We got the frequency of the vortex shedding to be around 70 Hz (this is where the peak is located in the graph). The graph doesn't change regardless of the Cp data that we enter. The only time the peak differs is when we change the sample frequency. It seems like the increase in the frequency of vortex shedding is proportional to the sample frequency and this doesn't seem to make sense at all. Any help regarding establishing a relation between sample frequency and vortex shedding frequency would be greatly appreaciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

云胡 2024-07-14 20:05:20

我认为在开始理解 DFT (FFT) 的所有细微差别之前,您需要认真阅读有关数字信号处理的内容。 如果我是你,我会首先通过这本伟大的书来扎根:

Discrete-时间信号处理

如果您想要更多能够真正扩展您能力的数学处理,

Körner 的傅里叶分析

Methinks you need to do some serious reading on digital signal processing before you can even begin to understand all the nuances of the DFT (FFT). If I was you, I'd get grounded in it first with this great book:

Discrete-Time Signal Processing

If you want more of a mathematical treatment that will really expand your abilities,

Fourier Analysis by Körner

一直在等你来 2024-07-14 20:05:20

查看相关问题。 虽然最初被问及有关 VB 的问题,但答复一般都是有关 FFT 的

Take a look at this related question. While it was originally asked about asked about VB the responses are generically about FFTs

傻比既视感 2024-07-14 20:05:20

我尝试使用上面的频率响应代码,但似乎我在 Matlab 中没有合适的工具箱。 有没有办法在不使用 fft 命令的情况下做同样的事情? 到目前为止,这就是我所拥有的:

   % FFT Algorithm

Fs = 200;                     % Sampling frequency
T = 1/Fs;                     % Sample time
L = 65536;                    % Length of signal
t = (0:L-1)*T;                % Time vector
y = data1;                    % Your CP values go in this vector

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);

% Plot single-sided amplitude spectrum.
loglog(f,2*abs(Y(1:NFFT/2))) 
title(' y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

我认为我正在使用的代码可能有问题。 我不确定是什么。

I tried using the frequency response code as above but it seems that I dont have the appropriate toolbox in Matlab. Is there any way to do the same thing without using fft command? So far, this is what I have:

   % FFT Algorithm

Fs = 200;                     % Sampling frequency
T = 1/Fs;                     % Sample time
L = 65536;                    % Length of signal
t = (0:L-1)*T;                % Time vector
y = data1;                    % Your CP values go in this vector

NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);

% Plot single-sided amplitude spectrum.
loglog(f,2*abs(Y(1:NFFT/2))) 
title(' y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

I think there might be something wrong with the code I am using. I'm not sure what though.

梦断已成空 2024-07-14 20:05:20

我的一位同事编写了一些很好的 GPL 许可函数用于频谱分析:
http://www.me Cheng.adelaide.edu.au/~pvl/octave /

更新:此代码现在是 Octave 模块之一的一部分:
http://octave.svn.sourceforge .net/viewvc/octave/trunk/octave-forge/main/signal/inst/
但从那里提取您需要的部分可能会很棘手。)

它们是为 Matlab 和 Octave 编写的,主要用作信号处理工具箱中类似函数的直接替代。 (因此上面的代码应该仍然有效很好。)

它可能有助于您的数据分析; 比使用 fft 等自行推出更好。

A colleague of mine has written some nice GPL-licenced functions for spectral analysis:
http://www.mecheng.adelaide.edu.au/~pvl/octave/

(Update: this code is now part of one of the Octave modules:
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/signal/inst/.
But it might be tricky to extract just the pieces you need from there.)

They're written for both Matlab and Octave and serve mostly as a drop-in replacement for the analogous functions in the Signal Processing Toolbox. (So the code above should still work fine.)

It may help with your data analysis; better than rolling your own with fft and the like.

草莓酥 2024-07-14 20:05:19

您看到的问题与“数据混叠”有关,因为 FFT 无法检测到高于 奈奎斯特频率(采样频率的一半)。

对于数据混叠,实际频率的峰值将以(实际频率奈奎斯特频率)为中心。 在 20 Hz 采样中(假设 70 Hz 是真实频率,这会导致频率为零,这意味着您看不到真正的信息。可以帮助您解决此问题的一件事是使用 FFT“窗口”。

您需要解决的另一个问题可能遇到的问题与通过单次 FFT 测量生成噪声数据有关 最好获取大量数据,使用重叠加窗,并确保至少有 5 个 FFT 的平均值才能找到结果。如果可能的话,您还应该以更快的速率进行采样。

最后,我建议您阅读 C 语言的数值方法(<-- 链接):

您不需要阅读 C 源代码——只需阅读解释。 Numerical Recipes for C 提供了有关该主题的极好的浓缩信息。

如果您还有其他问题,请在评论中留下。 我会尽力回答他们。

祝你好运!

The problem you are seeing is related to "data aliasing" due to limitations of the FFT being able to detect frequencies higher than the Nyquist Frequency (half-the sampling frequency).

With data aliasing, a peak in real frequency will be centered around (real frequency modulo Nyquist frequency). In your 20 Hz sampling (assuming 70 Hz is the true frequency, that results in zero frequency which means you're not seeing the real information. One thing that can help you with this is to use FFT "windowing".

Another problem that you may be experiencing is related to noisy data generation via single-FFT measurement. It's better to take lots of data, use windowing with overlap, and make sure you have at least 5 FFTs which you average to find your result. As Steven Lowe mentioned, you should also sample at faster rates if possible. I would recommend sampling at the fastest rate your instruments can sample.

Lastly, I would recommend that you read some excerpts from Numerical Recipes in C (<-- link):

You don't need to read the C source code -- just the explanations. Numerical Recipes for C has excellent condensed information on the subject.

If you have any more questions, leave them in the comments. I'll try to do my best in answering them.

Good luck!

我很坚强 2024-07-14 20:05:19

这可能不是一个编程问题,这听起来像是一个实验测量问题,

我认为采样频率必须至少是振荡频率的两倍,否则你会得到伪影; 这也许可以解释这种差异。 请注意,两种情况下 FFT 频率与采样频率的比率均为 0.35。 你能用更高的采样率重复这个实验吗? 我在想,如果这是一个强风中的狭窄圆柱体,它的振动/振荡速度可能比采样率可以检测到的速度要快。

我希望这会有所帮助 - 有 97.6% 的可能性我不知道我是什么我正在谈论;-)

this is probably not a programming problem, it sounds like an experiment-measurement problem

i think the sampling frequency has to be at least twice the rate of the oscillation frequency, otherwise you get artifacts; this might explain the difference. Note that the ratio of the FFT frequency to the sampling frequency is 0.35 in both cases. Can you repeat the experiment with higher sampling rates? I'm thinking that if this is a narrow cylinder in a strong wind, it may be vibrating/oscillating faster than the sampling rate can detect..

i hope this helps - there's a 97.6% probability that i don't know what i'm talking about ;-)

陌路终见情 2024-07-14 20:05:19

如果这不是混叠问题,听起来您可以在标准化频率标度上绘制频率响应,该频率标度将随采样频率而变化。 下面是在 Matlab 中绘制信号频率响应的相当好的方法的示例:

Fs = 100;
Tmax = 10;
time = 0:1/Fs:Tmax; 
omega = 2*pi*10; % 10 Hz
signal = 10*sin(omega*time) + rand(1,Tmax*Fs+1);

Nfft = 2^8;
[Pxx,freq] = pwelch(signal,Nfft,[],[],Fs)
plot(freq,Pxx)

请注意,采样频率必须显式传递给 pwelch 命令才能输出“真实”频率数据。 否则,当您更改采样频率时,发生共振的频率似乎会发生变化,这与您描述的问题类似。

If it's not an aliasing problem, it sounds like you could be plotting the frequency response on a normalised frequency scale, which will change with sample frequency. Here's an example of a reasonably good way to plot a frequency response of a signal in Matlab:

Fs = 100;
Tmax = 10;
time = 0:1/Fs:Tmax; 
omega = 2*pi*10; % 10 Hz
signal = 10*sin(omega*time) + rand(1,Tmax*Fs+1);

Nfft = 2^8;
[Pxx,freq] = pwelch(signal,Nfft,[],[],Fs)
plot(freq,Pxx)

Note that the sample frequency must be explicitly passed to the pwelch command in order to output the “real” frequency data. Otherwise, when you change the sample frequency the bin where the resonance occurs will seem to shift, which is similar to the problem you describe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文