How to find the coordinates of contours when they go out of bounds and form multiple contours?
Show older comments
I am trying to get the coordinates of the contour lines that go out of the bounds of plot resulting in division of line. As I am running multiple loops, I intend to keep the lines together or just join the two lines by adding points along the bounds of the plot. For example, it would be acceptable if the line shown in the plot below travels along horizontal axis from 12 to 54.
load('contours.mat')
pk = -32;
[c2] = contourf(x2,y2,z35b, [pk pk] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='#D95319'); axis equal
The problem is, when I retreive the coordinates stored in contour plot, first, it adds additional points (probably due to some additional peaks too small to be visible probably) which when joined gives random additional points (shown by blue lines below) which are not desirable for my code.
figure
[c2] = contourf(x2,y2,z35b, [pk pk] ,'ShowText','on',FaceAlpha=0.2,EdgeAlpha=0.5,EdgeColor='#D95319');
hold on
c2 = c2';
plot(c2(:,1),c2(:,2),'.:',MarkerEdgeColor='r')
axis equal
My failed approaches:
I tried to use approaches like using fit but it does not work (output shown below).

I also tried using sort but it also gives similar results.
I would like to find a solution where the best case scenario is tha that the lines travel along the contour and where it goes out of bounds, it just travels along the boundary until it meets the next line(as hand drawn for demonstration by yellow line in figure below). I shall be thankful for the help in achieving the desired results.

Accepted Answer
More Answers (0)
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



