Question related to area trapz
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
vivek patel
am 20 Dez. 2024
Kommentiert: vivek patel
am 20 Dez. 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.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 20 Dez. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!