查看单个帖子
旧 2019-12-10, 20:30   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 在MATLAB中计算FFT图下的面积

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

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



回答:

有很多方法可以与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')

更多&回答...
poster 当前离线   回复时引用此帖