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

Star Strider
Star Strider 2021년 8월 13일
Please do not name your function contour! This overshadows the contour function.
.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2021년 8월 13일

0 개 추천

Read about polyarea. You got (X,Y) coordinates of contour.

댓글 수: 3

J Ed
J Ed 2021년 8월 13일
If I add a line which says
a = polyarea(xValues, yValues)
Then I just get back a string filled with 0s?
KSSV
KSSV 2021년 8월 13일
You have to check each level and find out is region closed or not.
J Ed
J Ed 2021년 8월 13일
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