how to find area enclosed by ezplot

4 views (last 30 days)
I have bean curve equation and plotted it using ezplot. I wold like to find out the area enclosed by the curve. Tried to do get gca and extracting x and y only gives me a straight line and not a bean curve. Tried plotting CountourMatrix but gives error. syms x y; f=ezplot((a*x)^4+(a*x)^2*(b*y)^2+(b*y)^4-a*x*((a*x)^2+(b*y)^2));axis equal; title('bean');
code : get(f); Q=get(f,'ContourMatrix'); gives error message: Error using hg.axes/get The name 'ContourMatrix' is not an accessible property for an instance of class 'axes'
Please help

Accepted Answer

Star Strider
Star Strider on 14 Apr 2015
The ezplot function is not the best way to go with your problem. Use contour instead:
a = 0.3;
b = 0.5;
[X,Y] = meshgrid(linspace(-5, 5, 50));
beanfcn = @(x,y) (a*x).^4+(a*x).^2.*(b*y).^2+(b*y).^4-a*x.*((a*x).^2+(b*y).^2);
hc = contour(beanfcn(X,Y), [0; 0]);
BeanArea = polyarea(hc(1,2:end), hc(2,2:end))
produces (for these values of ‘a’ and ‘b’):
BeanArea =
167.1371
  4 Comments
komal shah
komal shah on 15 Apr 2015
Edited: komal shah on 15 Apr 2015
Ok, Now I understand what is linespace. I created the curve with (-5,5,500) points and get a very smooth curve. Thanks Star Strider. My problem is solved and I learn something new with the contour plot. Thank you, much appreciated.
Star Strider
Star Strider on 15 Apr 2015
My pleasure!
I use contour frequently when I need to find zeros (or any other constant values) of functions of two variables.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!