Question related to area trapz

6 visualizaciones (últimos 30 días)
vivek patel
vivek patel el 20 de Dic. de 2024
Comentada: vivek patel el 20 de Dic. de 2024
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Dic. de 2024
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 comentario
vivek patel
vivek patel el 20 de Dic. de 2024
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by