dimanche 12 avril 2015

Matlab trapz not giving the correct area value (Incorrect equilibrium position)


Vote count:

0




I want to find the equilibrium position of a sinus curve (for which the argument linearly decreases with increasing x) using the matlab function trapz but it does not give the right equilibrium position. In the following plot there is plotted two curves both are almost 1 wave(from 0 to 2pi phase). Because the sine wave is centered around 0 the area of 1 wave will be the equilibrium position.


(Can not show the picture, I do not have enough reputation (first time posting something) this is the figure on imgur, if this is not allowed to link to another site let me know and I will delete it as soon as possible http://i.imgur.com/m3eoPE6.jpg)


I know what the equilibrium position needs to be of the two lines, for the blue line it needs to be 0 and after applying trapz it gives as good as 0 for this problem( -3.1057e-04 exactly). But the problem arises now, I know that the red line has its equilibrium position at around 0.22 but the function trapz gives 0.0029 back, somethings going wrong... I apply the mean on the array to get a first order approximation of the equilibrium and I get back that for the blue line the mean is -0.022 and for the red line it is 0.1993 (Close by the 0.22 which it needs to be).


So my question is what is going wrong? Why does trapz not give back the right area which is in this case the equilibrium position. Is something going wrong with the calculation of the area beneath 0? Is there maybe a better way to calculate the equilibrium position?


How I call to trapz, I am pretty sure that everything before is going well. I am 99.9% sure that the two arrays on which I use trapz got the right data in it (made sure by checking multiple times the arrays):



mean(Right_ShortSpSm)
Trapz1 = 0.00001*trapz(Right_ShortSpSm)
mean(Right_ShortSpSm2)
Trapz2 = 0.00001*trapz(Right_ShortSpSm2)


I am using the numerical integration function trapz and not the integral function because I do not know the underlying function of the two curves. And I suspect trapz giving a better value then the mean due to the steps in my array are to large for giving the correct equilibrium position by using mean.



asked 13 secs ago







Matlab trapz not giving the correct area value (Incorrect equilibrium position)

Aucun commentaire:

Enregistrer un commentaire