Find two contours at different levels around the same peak
Show older comments
Hi.
I would like to find two contours at different levels around the same lower peak and only keep those where this is true. I also want to reference two contours at different heights to each other. I assume the contour function is kind of random.
Let's say I have two different thresholds for two different levels. How can I find all the contours for threshold2 where also contours for threshold1 exist.
Threshold1 is lower than threshold2.
In the code example below I would only be interested in the two contours around the lower peak and I want to disregard or reject the other contour where no threshold1 contour exists.
In the example I only have two lower peaks but If I have many more lower peaks I would like to reference the contours to each other so that I know which contour at threshold2 is drawn around the same lower peak as for threshold1.
[X,Y,Z] = peaks(1000);
figure(1),hold on
view(2);
colorbar('vert');
s = surf(X,Y,Z,'Facealpha',0.75,'Edgecolor','none');
% threshold = -0.3*max(Z,[],'all');
threshold1 = [-6, -6];
threshold2 = [-3, -3];
[c1,h1] = contour(X,Y,Z,[threshold1 threshold1],'-k','Linewidth',5);
[c2,h2] = contour(X,Y,Z,[threshold2 threshold2],'-k','Linewidth',5);
hold off

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