find nearest value on mesh grid under certain contour
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a surf matrix (colormap gray), a contour matrix (red). The magenta points are local minmum in red contours. I want to find the closest z value on the neigbhourhood contours. Is there any way to achieve this?
7 comentarios
Bruno Luong
el 4 de Sept. de 2022
For each magenta point do you want to find the z value on the contour that enclosed the point? If the pointt is the locall minima, meaning that do you want to find the lowest Z along the contour?
Respuestas (1)
Chunru
el 4 de Sept. de 2022
load(websave("matlab.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1116160/matlab.mat"))
% whos
surf(Xi2,Yi2,Zi2-max(Zi2(:)));
axis tight; title('m-min y-max')
colormap(gray); colorbar; %daspect([1 1 5]);
hold on
% red contour
surf(Xi2,Yi2,B2,'EdgeColor','r')
% peak and valley points
scatter3(Xi2(regmin),Yi2(regmin),Zi2(regmin),'mo','filled','sizedata',40)
scatter3(Xi2(regmax),Yi2(regmax),Zi2(regmax),'yo','filled','sizedata',40)
idxB2 = ~isnan(B2); % B2 has values of 0 and nans
% The values along the countour
Xc = Xi2(idxB2);
Yc = Yi2(idxB2);
Zc = Zi2(idxB2);
% These are values along the countour
[Xc Yc Zc]
0 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!