Extract the information of inside and outside of a contourf

10 次查看(过去 30 天)
Hello everyone,
I have a single line of code, quite simple, thanks to which I get (visually) exactly what I need:
h=figure; [pippo1, pippo2]=contourf(AZ,EL,FF, [0, 0]);
where the input arguments have size 301x301. The plot I get is like this:
As you can see, the outside of the contour is not only the big cyan area, but also some small areas in the white (not filled) polygon. I need the coordinates of the outside polygon (the whole cyan region) but I couldn't extract them from either "h" or "pippo2". Please note, I DON'T NEED the coordinates of the single contours, because if I extract XDATA and YDATA they lose the information about "the inside" and the "outside". I need to extract, in some way, a single contour that represents the whole cyan area, and another one that represents the complementary (white) one.
Thanks a lot!

回答(1 个)

Star Strider
Star Strider about 20 hours 前
Tthey are in ‘pippo1’ . In order to extract them, you need to know the level.
The ‘pippo1’ matrtix is arranged as:
pippo1 = [level x-coordinates level x-coordinates; number y-coordinates number y-coordinates]
as described in M in the contour documentation.
This prototype code will work tto extract them —
[X,Y,Z] = peaks;
figure
[M,C] = contour(X, Y, Z, 'ShowText',1);
Levels = C.LevelList
for k = 1:numel(Levels)
idx = find(M(1,:) == Levels(k));
ValidV = rem(M(2,idx),1) == 0;
StartIdx{k,:} = idx(ValidV);
VLen{k,:} = M(2,StartIdx{k});
end
.
  2 个评论
Roberto Tumolo
Roberto Tumolo about 20 hours 前
But I have a single level, which is 0, as in the code I posted. In pippo1 I just have the coordinates of the cntours, not the (binary in this case) information regarding the inside or the outside
Star Strider
Star Strider about 19 hours 前
If you only have one level, extract the coordinates as I described, the see what the values of the original matrix are on either side of them. Another option is to use perhaps three closely-spaced levels, and then see where they are in relation to the zero level. You can ignore the other levels in you subsequent analyses, since tthey only serve to identify the relative values around the zero level.
Without your data and relevant code to create the contourf arguments, I can do nothing specific, only descriptive.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by