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

 채택된 답변

Mike Garrity
Mike Garrity 2015년 4월 16일

4 개 추천

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.

댓글 수: 1

Jared Salloum
Jared Salloum 2015년 4월 17일
Thanks Mike, the scatter3 function is what I needed. I already had values and co ordinates for maximums and minimums to display to the user when they called the function I wrote, I just needed a way to pin point a marker on my surface plot, thank you. As a follow up to this, is there a way to include a caption on the marker? thanks again

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2015년 4월 16일

댓글:

2015년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by