Evaluating the area between two curves.

how to Evaluate the area between two curves using matlab? for example this one y=x^2 and y=2*x

댓글 수: 2

kalash vasaniya
kalash vasaniya 2021년 11월 8일
Find the area of the region bounded by the curves x=y^3 and x=y^2 in matlab
syms x y
fimplicit([x == y^3, x == y^2], [-1 10])
Which of the two areas? The right-hand one is obviously unbounded, but your instructions do not say to do only the other area.
And please explain how your instructions will solve the question asked 10 years ago by Ejay Kasai ??

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

답변 (2개)

Grzegorz Knor
Grzegorz Knor 2011년 9월 12일

2 개 추천

In your case:
syms x
x0 = eval(solve('x^2 -2*x'));
x = linspace(x0(1),x0(2),100);
y1 = x.^2;
y2 = 2*x;
fill([x x(end:-1:1)],[y1 y2(end:-1:1)],'r')
hold on
plot(x,y1,x,y2,'LineWidth',2)
grid on
a = trapz(x,y2)-trapz(x,y1);
Instead of:
syms x
x0 = eval(solve('x^2 -2*x'));
You can use:
x0(1) = fzero('x.^2 -2*x',1);
x0(2) = fzero('x.^2 -2*x',1.5);

댓글 수: 6

Ejay Kasai
Ejay Kasai 2011년 9월 12일
i mean determining the value not by shading.
Oleg Komarov
Oleg Komarov 2011년 9월 12일
So, you're not happy with "a"?
Ejay Kasai
Ejay Kasai 2011년 9월 12일
what do you mean i'm not happy with ''a''? i really need the value. :( so please if you know the code share it to me.
Oleg Komarov
Oleg Komarov 2011년 9월 12일
Grzegorz has given you a valid solution. If you really needed the value you wouldn't have posted the comment in the first place since it's in the code.
Ejay Kasai
Ejay Kasai 2011년 9월 13일
i mean i need a code to evaluate the area between the two curves. i need to make a matlab program for that.
Walter Roberson
Walter Roberson 2011년 9월 13일
The expression Grzegorz gave, a = trapz(x,y2)-trapz(x,y1) *is* the code to evaluate the area between the two curves. This is elementary calculus: the area between two curves is the difference between their integrals. trapz() calculates numeric integrals.

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

Shyam babu
Shyam babu 2023년 7월 8일

0 개 추천

find the area included between the curves y^2=4*x & x^2=4*y

댓글 수: 1

Walter Roberson
Walter Roberson 2023년 7월 8일
I do not seem to understand how this would solve the question posted by @Ejay Kasai ??

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

카테고리

질문:

2011년 9월 12일

댓글:

2023년 7월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by