computing area between 2 curves

I have two curves from the 2 vetctors as a result of simulation. I want to find the area between these 2 curves. The curves are intersecting many times.
any ideas are appreciated!!

 채택된 답변

AC
AC 2012년 7월 4일

0 개 추천

Hi,
From scratch, you could try something like:
1/2*(abs(C1(2:end)-C2(2:end))+abs(C1(1:end-1)-C2(1:end-1)))*diff(I)'
where C1 and C2 are your curves and I the x-axis.
This will give you an estimate of the integral of C1(t)-C2(t) dt for t in I.
Cheers,
AC

댓글 수: 4

AC
AC 2012년 7월 4일
Sorry that didn't print out right: the estimate of the integral of the absolute value of C1-C2.
Vijay
Vijay 2012년 7월 9일
Thank you AC for hte brief explanation. In you formula, what do you mean by I which you used in diff(I)?
see doc diff
If X is a vector, then diff(X) returns a vector, one element shorter than X, of differences between adjacent elements.
Vijay
Vijay 2012년 7월 23일
if X is a vector from 1:10 say X-axis. then diff(X) is a vector of '1' nine times. What is the use of multiplying it??

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Luffy
Luffy 2012년 7월 3일

0 개 추천

If u know the vectors then try using polyarea & subtract them

댓글 수: 3

Vijay
Vijay 2012년 7월 3일
Thanks for the answer.
I know the vectors. They are column vectors. I computed the polyarea with those 2 vectors... what did you mean by substraction?
I put too much thought into it,ws thinking about finding area covered by each curve with x axis and then subtracting them to get area between them.
Happy to know polyarea helped you
AC
AC 2012년 7월 4일
Hi,
Substracting the two areas is ok if the curves don't cross and you substract in the right order (that is: highest - lowest). Otherwise you will end up with a wrong result. For example, take sin(x) and cos(x) between 0 and 2: int cos(t)-sin(t) dt = -0.5 approx. int abs(cos(t)-sin(t)) dt= 1.33 approx.
It's the second one that you want. So you should compute the area of the difference in absolute value (see my response below). Cheers,
AC

댓글을 달려면 로그인하십시오.

카테고리

질문:

2012년 7월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by