MATLAB: How to find area enclosed by ezplot

ezplot

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

Best Answer

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
Related Question