在MATLAB中计算FFT图下的面积 [英] Calculate area under FFT graph in MATLAB

查看:168
本文介绍了在MATLAB中计算FFT图下的面积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我对一组数据进行了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?

推荐答案

有许多方法可以与Matlab进行数值积分.这是一个示例:

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')

这篇关于在MATLAB中计算FFT图下的面积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆