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 个评论

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

请先登录,再进行评论。

回答(1 个)

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

3 个评论

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?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Line Plots 的更多信息

产品

版本

R2020a

提问:

2021-8-13

评论:

2021-8-13

Community Treasure Hunt

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

Start Hunting!

Translated by