Re: How to find the area of 2 polynomials?
- From: "John D'Errico" <woodchips@xxxxxxxxxxxxxxxx>
- Date: Wed, 6 Sep 2006 08:51:32 -0400
mango wrote:
I'm working out a matlab function recently, i came across a
difficulty to find the area of 2 different polynomials. For
example:
x=[0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
y=[-0.447 1.978 3.28 6.16 7.08 7.34 7.66 9.56 9.48 9.30 11.2];
p = polyfit(x,y,2);
z = polyval(p,x);
plot(x,y,'r-',x,z,'b')
%how to find the area at the intersection of the 2polynomials? I
mean
the area bounded by 2curves(the polyfit curve and the original
curve). Thanks.
I assume that you intend to find the
integral of the absolute value of the
difference between the two?
Simplest is to interpolate both curves
at many points, and use trapz on the
result. Interpolate the original data
with interp1 using the 'linear' method.
Evaluate the polynomial using polyval.
This will not be exact, but reasonably
close if you take enough points. If you
want the exact solution, it is not too
hard, but probably not worth the effort.
HTH,
John D'Errico
.
- Follow-Ups:
- Re: How to find the area of 2 polynomials?
- From: mango
- Re: How to find the area of 2 polynomials?
- References:
- How to find the area of 2 polynomials?
- From: mango
- How to find the area of 2 polynomials?
- Prev by Date: Re: double arrow between two points
- Next by Date: Re: Get MATLAB root from OS
- Previous by thread: How to find the area of 2 polynomials?
- Next by thread: Re: How to find the area of 2 polynomials?
- Index(es):
Relevant Pages
|