在 MATLAB 中计算 FFT 图下的面积

发布于 2024-08-28 13:09:23 字数 123 浏览 8 评论 0原文

目前,我对一组数据进行了 FFT,得到了 x 轴上的频率和 y 轴上的幅度的图。我想计算图表下方的面积来给我能量。

我不确定如何确定面积,因为我没有方程,而且我只想要图的某个区域而不是图下的整个区域。我有办法做到吗?

Currently I did a FFT of a set of data which gives me a plot with frequency at x axis and amplitude at y axis. I would like to calculate the area under the graph to give me the energy.

I am not sure how to determinate the area because I am without the equation and also I only want a certain area of the plot rather than whole area under the plot. Is there a way I can do it?

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

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

发布评论

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

评论(2

同展鸳鸯锦 2024-09-04 13:09:23

使用 Matlab 进行数值积分的方法有很多种。这是一个例子:

%# create some data
x = linspace(0,pi/2,100); %# 100 equally spaced points between 0 and pi/2
y = sin(x);

%# integrate using trapz, which calculates the area in the trapezoid defined by 
%# x(k),x(k+1),y(k),y(k+1) for k=1:length(x)
integral = trapz(x,y);

%# if you only want to integrate part of the data, do
partialIntegral = trapz(x(10:20),y(10:20));

%# show the integrated area
figure, 
area(x,y); 
hold on, 
area(x(10:20),y(10:20),'FaceColor','red')

There are many ways to do numerical integration with Matlab. Here is an example:

%# create some data
x = linspace(0,pi/2,100); %# 100 equally spaced points between 0 and pi/2
y = sin(x);

%# integrate using trapz, which calculates the area in the trapezoid defined by 
%# x(k),x(k+1),y(k),y(k+1) for k=1:length(x)
integral = trapz(x,y);

%# if you only want to integrate part of the data, do
partialIntegral = trapz(x(10:20),y(10:20));

%# show the integrated area
figure, 
area(x,y); 
hold on, 
area(x(10:20),y(10:20),'FaceColor','red')
榆西 2024-09-04 13:09:23

FFT 是离散的,而不是连续的 - 您只需将所有 bin 值相加即可。如果您正在查看功率谱(幅度平方),那么箱值的单位是 W/Hz,因此您需要将每个值(或者只是总和)乘以以 Hz 为单位的箱宽度以获得功率(并且因此是输入样本中的总能量)。

The FFT is discrete, not continuous - you just need to sum all the bin values. If you're looking at the power spectrum (magnitude squared) then the bin values are in W/Hz, so you would need to multiply each value (or alternatively just the sum), by the bin width in Hz to get power (and hence the total energy in your input sample).

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