如何用MATLAB计算曲线下的部分面积? [英] How do I calculate the partial area under a curve with MATLAB?

查看:99
本文介绍了如何用MATLAB计算曲线下的部分面积?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 matlab 的新手,并试图找到图形的一部分而不是整个图形的曲线下面积 (AUC).我有兴趣从 2 个区域计算单独的 AUC;一个从 -350 到 -100 和另一个从 -100 到 +150 出现在 x 轴上.如何计算图形这些部分的 AUC(不是整个 x 轴)?没有足够的声誉来提供这个数字.如果社区中有人可以提供 matlab 代码.

I am a newbie to matlab and trying to find the area under the curve (AUC) for a part of the graph not the entire graph. I am interested to calculate separate AUC from 2 regions; one from -350 to -100 and other from -100 to +150 present on the x axis. how can I calculate AUC for these portion of the graph (not for entire x-axis)? not enough reputation to provide the figure. If someone from the community can provide a matlab code.

数据集中的每一对值都对应于 x,y 坐标.如果绘制,这些点会生成单独的 (x,y) 曲线,其中 x 是从 -750 到 +750 的固定列.
y 数据有 N 行,类似于

Every couple of values in the data set correspond to x,y coordinates. If plotted, these points generate individual (x,y) curve, where x is a fixed column from -750 to +750.
y data has N rows, something like

x = [-750:25:750];

y1 = [1.52,0.47,0.59,0.62,1.88,...];    
y2 = [1.5,0.79,0.74,1.46,0.6,...];  
y3 = [1.6,0.11,0.79,0.77,1.33,...];

yn = [0.061,0.0609,0.05948,0.0624,0.067,0.073347639,...];

...未提供完整数据集.

...full data set not provided.

我想计算 x 轴上 -350 到 -100 区域和 -100 到 +150 区域的 AUC,对于 (x,y) 的每个组合,例如 (x,y1), (x,y2)..

I want to calculate AUC for -350 to -100 region and from -100 to +150 region present on the x axis, for each combination of (x,y), say (x,y1), (x,y2)..

推荐答案

尝试这样的事情(使用 trapz):

Try something like this (using trapz):

startingIndex = find(x==-350);
endingIndex = find(x==-100);

desiredX = x(startingIndex:endingIndex);
desiredY = y1(startingIndex:endingIndex);
area = trapz(desiredX,desiredY);

http://www.mathworks.com/matlabcentral/newsreader/view_thread 上找到/278102

基本上它会在 x 数组中找到端点的索引,然后根据相应的截断的 y 向量计算曲线下的面积.

basically it finds the index of the end points in the x array and then calcs the area under the curve from the corresponding truncated y vector.

这篇关于如何用MATLAB计算曲线下的部分面积?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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