在 Matlab 中查找低于最大值的某个值

发布于 2024-08-22 02:00:18 字数 249 浏览 4 评论 0原文

我在 Matlab 中有 2 800x1 数组,其中包含幅度与频率数据,一个数组包含幅度,另一个数组包含相应的频率值。我想找到振幅减小到最大值一半时的频率。

最好的方法是什么?我想我的两个主要问题是:如果“半振幅”值位于两个数据点之间,我怎样才能找到它? (例如,如果我要查找的值是 5,如果它位于 4 和 6 等两个数据点之间,我如何“在我的数据中找到它”?)

如果我找到“半振幅”值,如何然后我找到相应的频率值?

预先感谢您的帮助!

I have 2 800x1 arrays in Matlab which contain my amplitude vs. frequency data, one array contains the magnitude, the other contains the corresponding values for frequency. I want to find the frequency at which the amplitude has reduced to half of its maximum value.

What would be the best way to do this? I suppose my two main concerns are: if the 'half amplitude' value lies between two data points, how can I find it? (e.g. if the value I'm looking for is 5, how can I "find it in my data" if it lies between two data points such as 4 and 6?)

and if I find the 'half amplitude' value, how do I then find the corresponding value for frequency?

Thanks in advance for your help!

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

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

发布评论

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

评论(2

放手` 2024-08-29 02:00:18

您可以通过以下方式找到您感兴趣的点附近的索引

idx = magnitudes >= (max(magnitude)/2);

然后您可以通过以下方式查看所有相应的频率,包括峰值

disp(frequencies(idx))

如果您想查看更少的内容,可以在idx计算中添加更多条件无关的东西。

然而,您对找到确切频率的担忧更难回答。这在很大程度上取决于信号的性质以及窗口函数的线形。一般来说,您最好尝试用几个点来表征您的峰值,然后进行某种曲线拟合。您是否想计算谐振滤波器的 Q 值?

You can find the index near your point of interest by doing

idx = magnitudes >= (max(magnitude)/2);

And then you can see all the corresponding frequencies, including the peak, by doing

disp(frequencies(idx))

You can add more conditions to the idx calculation if you want to see less extraneous stuff.

However, your concern about finding the exact frequency is harder to answer. It will depend heavily on the nature of the signal and also on the lineshape of your window function. In general, you might be better off trying to characterize your peak with a few points and then doing a curvefit of some kind. Are you trying to calculate Q of a resonant filter, by any chance?

桜花祭 2024-08-29 02:00:18

如果可以的话,你可以做简单的线性插值。找到发生下降的段并计算中间值。如果您期望信号中存在噪声,那就不好了。

idx = find(magnitudes(2:end) <= (max(magnitudes)/2) & ...
    magnitudes(1:end-1) >= (max(magnitudes)/2));
mag1 = magnitudes(idx); % magnitudes of points before drop
mag2 = magnitudes(idx+1); % magnitudes of points after drop below max/2
fr1 = frequencies(idx); % frequencies just before drop
fr2 = frequencies(idx+1); % frequencies after drop below max/2
magx = max(magnitudes)/2; % max/2
frx = (magx-mag2).*(fr1-fr2)./(mag1-mag2) + fr2; % estimated frequencies

您还可以使用 INTERP1 功能。

If it's ok, you can do simple linear interpolation. Find segments where the drop occurs and calculate intermediate values. That will be no good, if you expect noise in the signal.

idx = find(magnitudes(2:end) <= (max(magnitudes)/2) & ...
    magnitudes(1:end-1) >= (max(magnitudes)/2));
mag1 = magnitudes(idx); % magnitudes of points before drop
mag2 = magnitudes(idx+1); % magnitudes of points after drop below max/2
fr1 = frequencies(idx); % frequencies just before drop
fr2 = frequencies(idx+1); % frequencies after drop below max/2
magx = max(magnitudes)/2; % max/2
frx = (magx-mag2).*(fr1-fr2)./(mag1-mag2) + fr2; % estimated frequencies

You can also use INTERP1 function.

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