Area for contour plot - object oriented

I am looking for a way to calculate the area of a contour plot, which uses an object oriented function. I have a table of objects of which I am importing a section of the values to create the contour plot and I am succesfully plotting the graph, so I know this section of the code works. I am sure it is a simple solution but all examples I can find refer to [X Y] = contour(A,B,C) system and I am unsure of how to translate.
Help would be appreciated.
Code:
function obj = contour(obj,ref)
if ~exist('ref','var'); ref = 1; end
obj.contourFig = figure();
obj.contourAx = axes(obj.contourFig);
[xValues,yValues] = meshgrid(obj.MyObjects(ref).xValues,obj.MyObjects(ref).yValues);
zMin = 10;
zInc = 10;
zMax = obj.MyObjects.maxPower;
zLevels = zMin:zInc:zMax;
contour(obj.contourAx,xValues,yValues,obj.MyObjects(ref).powerData,zLevels);
grid off
title(obj.MyObjects.filename)
end

1 Comment

Please do not name your function contour! This overshadows the contour function.
.

Sign in to comment.

Answers (1)

KSSV
KSSV on 13 Aug 2021
Read about polyarea. You got (X,Y) coordinates of contour.

3 Comments

If I add a line which says
a = polyarea(xValues, yValues)
Then I just get back a string filled with 0s?
You have to check each level and find out is region closed or not.
I don't understand what that means?

Sign in to comment.

Categories

Products

Release

R2020a

Asked:

on 13 Aug 2021

Commented:

on 13 Aug 2021

Community Treasure Hunt

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

Start Hunting!