point coordinate markers of selected points

조회 수: 21 (최근 30일)
fima v
fima v 2017년 3월 17일
답변: Image Analyst 2017년 3월 17일
Hello how can i present automatickly the coordinate data marker of the selected 'or' points? Thanks
plot(x, y, 'g');
hold('on');
index = (5 < y & y < 7);
plot(find(index), y(index), 'or');
  댓글 수: 2
Jan
Jan 2017년 3월 17일
The question is not clear to me. What should happen when? What is the difference to your question https://www.mathworks.com/matlabcentral/answers/330192-marking-a-points-in-a-curve-that-match-condition? If you have problems with my answer given there, adding this as a comment would be useful.
fima v
fima v 2017년 3월 17일
i mean showing the value of the point not only as a circle but next to it will be a small yellow window the will show the (x,y) data of this point.

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

채택된 답변

Image Analyst
Image Analyst 2017년 3월 17일
Try this:
numPoints = 20;
offset = 0.05; % How much away from the marker the text should be.
x = sort(rand(1, numPoints));
y = 10 * rand(1, numPoints);
plot(x, y, 'g', 'LineWidth', 2);
hold on;
index = (5 < y & y < 7);
plot(x(index), y(index), 'or', 'LineWidth', 2);
grid on;
for k = 1 : length(y)
if index(k)
caption = sprintf('x=%.2f, y=%.2f', x(k), y(k));
text(x(k) + offset, y(k) + offset, caption, 'BackgroundColor', 'y');
end
end

추가 답변 (1개)

Thorsten
Thorsten 2017년 3월 17일
You don't need find, you can work with logical indices:
plot(x(index), y(index), 'or');

카테고리

Help CenterFile Exchange에서 Financial Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by