积分返回预定义区域所需的 y 值 [英] Integration returning required y value for predefined area

查看:23
本文介绍了积分返回预定义区域所需的 y 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于以下内容:

  • 具有x(时间[s])和y(此处为排放[m³/s])的时间序列

  • Time series with x (time [s]) and y (here discharge [m³/s])

V1(相同单位y),小于x的积分.在这种情况下,体积较小 [m³].

Value V1 (same units integrated y), smaller than the integral over all of x. In this case a small volume [m³].

我想计算:

  • yy_V1 使得线 y = y_V1 和曲线 y 之间的积分code> 等于 V1.

  • The y value y_V1 such that the integral between the line y = y_V1 and the curve y equals V1.

下图显示了这一点,橙色区域是V1,我想要y 轴上的圆圈值:

The following plot shows this, the orange region is V1, I want the circled value on the y axis:

V1 必须放置在峰周围.

我认为这必须是一个迭代过程,其中还必须由用户设置拟合标准(以及精确度).

I think this must be an iterative process, where also a the fitting criteria (and the degree of exactness) must be set by the user.

直到现在,我还没有找到开始的方法;除了纯粹的整合.

Until now, I haven't found a way to start; besides the pure integration.

这个想法是指定一个区域.应计算包围该区域的峰左右的 y 值.

The idea is to specify an area. The y value left and right of the peak which envelops this area should be calculated.

编辑

这是结果,如果接受的答案被应用.

This is the result, if the accepted answer is applied.

推荐答案

您可以通过减少一些 y 值来实现此目的,直到达到您的区域目标.有关详细信息,请参阅下面的评论.

You can do this by decreasing some y value until your area target is met. See the comments below for details.

% Input data
x = 0:0.01:pi;
y = sin(x);

target = 1;     % Target area

yi = max( y );  % Initialise yi to be max possible y
dy = 0.001;     % Step change in yi

Ai = 0;         % Area each iteration
thresh = 0;     % Threshold for stopping loop
while target - Ai > thresh && yi >= min(y)
    yi = yi - dy;
    ix = y >= yi;
    % Approximate integral above the line
    Ai = trapz( x(ix), y(ix) - yi ); 
end

% Plot
figure(1); clf; hold on
plot( x, y );
patch( x(ix), y(ix), [1,0.5,0.5], 'facealpha', 0.5 );
plot( x, ones(size(x))*yi, '--', 'linewidth', 2 )
xlim( [min(x),max(x)] )

输出:

这篇关于积分返回预定义区域所需的 y 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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