Question related to area trapz

4 次查看(过去 30 天)
This might be a general question and not specific trapz function question. But i am not sure where to request the support.
I have a quantity(y) which is measured every x ms. Also, the quantity(y) ideally should be at a constant value C, but due to the limitations the quantity(y) is always (C1 + xx) < C. Wheren C1 is again a constant and the value xx can vary based on various conditions. Tried to represent the graph as below.
Now i want to find out how much percentage of time the quantity(y) is nearer to the ideal scenario. So, my idea was to calculate the percentage as below.
trapz(t,y)/trapz(t,C). Where C would be an array with constant value but same size as y array.
But the result i get is very high >90%, even though by graph i can see that it is definitely not the right value.
But when i subtract the constant C1 from the values, and then calculate the percentage i think i am getting it in proper values.
trapz(t,y-C1)/trapz(t,C-C1).
I am thinking there is an issue maybe because of my lack of understanding of the integration and mathematics but i am not able to figure out why.

采纳的回答

Walter Roberson
Walter Roberson 2024-12-20
If C1/C approaches 0.9 then it is normal that trapz(t,y)/trapz(t,C) would approach 0.9
Let's say that C1 is 8 and C is 10, then it would only take y being 50% high in order for trapz(t,y)/trapz(t,C) to reach 0.9
trapz(t,y-C1)/trapz(t,C-C1) in the same situation would generate 0.5, so trapz(t,y-C1)/trapz(t,C-C1) is the right way to go.
  1 个评论
vivek patel
vivek patel 2024-12-20
Thanks, yeah now it makes sense, i was just seeing the plot and was like okay ofcourse it is lesser.
But the matlab plot was starting from C1 instead of 0. When i see it with 0, then yes it makes sense.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by