
How to place a marker on a 3D surface plot
36 次查看(过去 30 天)
显示 更早的评论
I have a 3D surface plot for a function, and I need to place a marker on this plot at the maximum and minimum values within my range/domain. I have no idea how to do it and I really struggle to find what I am looking for in matlab help
0 个评论
采纳的回答
Mike Garrity
2015-4-16
Consider the following example:
[x,y,z] = peaks;
surf(x,y,z)
hold on
[~,i] = max(z(:));
h = scatter3(x(i),y(i),z(i),'filled');
h.SizeData = 150;
[~,i] = min(z(:));
h = scatter3(x(i),y(i),z(i),'filled');
h.SizeData = 150;
hold off

Does that make sense?
The 2nd arg of the min/max commands tells you the index of the element that is the min or max. You can use that index to get the X, Y, and Z coordinate for the surface.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!