MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在MATLAB图形中标记点? (https://www.labfans.com/bbs/showthread.php?t=22808)

poster 2019-12-10 16:49

如何在MATLAB图形中标记点?
 
我有这个情节

[ [URL="https://imgur.com/WTdmJ.jpg"]全分辨率[/URL] ]

[IMG]https://imgur.com/WTdmJ.jpg[/IMG]

我需要在X轴上的点,该[B]用户输入[/B]直线的[B]垂直[/B]线,并[B]显示[/B]我的阴谋是垂直线[B]的交叉点的坐标[/B] 。

如何在MATLAB中完成?

[B]例如:[/B]用户输入1020,则将在1020处绘制一条垂直的直线,该直线在某个点与绘图相遇,并且将以某种方式显示该点的坐标。


回答:
一种实现方法是使用[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ginput.html"]GINPUT[/URL]函数通过鼠标以图形方式选择一个点。假设您绘制的数据存储在变量data ,则以下代码应完成所需的操作。

set(gca,'XLimMode','manual','YLimMode','manual'); % Fix axes limits hold on; [x,y] = ginput(1); % Select a point with the mouse x = round(x); % Round x to nearest integer value y = data(x); % Get y data of intersection plot([xx],get(gca,'YLim'),'k--'); % Plot dashed line plot(x,y,'r*'); % Mark intersection with red asterisk disp('Intersection coordinates:'); disp([xy]); % Display the intersection point 以上假设图形的x值只是您要绘制的数据数组的索引,上面显示的图形似乎就是这种情况。



[url=https://stackoverflow.com/questions/1516740]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:43

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.