Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
目前,我对一组数据进行了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') 更多&回答... |
![]() |
![]() |