How to calculate the area between X-Axis, Y-Axis and the (60) contour line?

2 views (last 30 days)
How to calculate the area between X-Axis, Y-Axis and the (60) contour line?
Code of the contour line:
x = 1:0.2:2;
y = 1:0.2:3;
[X,Y] = meshgrid(x,y);
Z = 1000*(X.*exp(-X.^2-Y.^2));
contour(X,Y,Z,[20 60 80],'ShowText','on')

Accepted Answer

Matt J
Matt J on 24 Jan 2024
Edited: Matt J on 24 Jan 2024
Using this FEX download,
x = 1:0.2:2;
y = 1:0.2:3;
[X,Y] = meshgrid(x,y);
Z = 1000*(X.*exp(-X.^2-Y.^2));
cm=contour(X,Y,Z,[20 60 80],'ShowText','on');
[~, V]=getContourLineCoordinates(cm);
p=polyshape([1,1; V{2}]);
hold on;
plot(p);
hold off
Area=area(p)
Area = 0.1006

More Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!