Azzera filtri
Azzera filtri

Extract the information of inside and outside of a contourf

10 visualizzazioni (ultimi 30 giorni)
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!

Risposte (1)

Star Strider
Star Strider circa 20 ore fa
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 Commenti
Roberto Tumolo
Roberto Tumolo circa 19 ore fa
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 circa 19 ore fa
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.

Accedi per commentare.

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by