how to find area enclosed by ezplot
4 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!