Matlab 使用datacursor计算三维图形两点之间的距离
我正在构建一个GUI,通过按下按钮来绘制3D图形。当我在图上使用datacursormode选择2个点时,我试图返回2个点之间的距离值。我知道计算距离的公式,但我不知道如何使数据光标返回所选2个点的(X、Y、Z)值 谢谢Matlab 使用datacursor计算三维图形两点之间的距离,matlab,user-interface,figure,Matlab,User Interface,Figure,我正在构建一个GUI,通过按下按钮来绘制3D图形。当我在图上使用datacursormode选择2个点时,我试图返回2个点之间的距离值。我知道计算距离的公式,但我不知道如何使数据光标返回所选2个点的(X、Y、Z)值 谢谢 %// retrieve the data cursor manager for the figure dcm = datacursormode(gcf) ; %// get all the datatips information in a structure dt
%// retrieve the data cursor manager for the figure
dcm = datacursormode(gcf) ;
%// get all the datatips information in a structure
dtip_info = dcm.getCursorInfo ;
%// extract the coordinates of each data tip from the structure
Coordinates_Datatip1 = dtip_info(1).Position ;
Coordinates_Datatip2 = dtip_info(2).Position ;
这假设您在当前图中已经有2个数据提示。
每个“坐标\数据提示”变量将包含数据提示位置的3个标量值x、y和z。请分享一些代码,包括您尝试过的代码和未成功的代码。这将帮助社区为您提供答案。函数plot_回调(hObject,eventdata,handles)%hObject handle to plot(请参见GCBO)%eventdata reserved-将在未来版本的MATLAB中定义%handles结构,带有句柄和用户数据(请参见GUI数据)%open my save figure plot=open('figure.fig');%离开三维地物集的轴线(gca、‘可见’、‘关闭’)%激活地物上的光标datacursormode(绘图)%地物h的手柄=datacursormode(绘图)%我打算使用matlab函数计算两点之间的距离。%[x,y,z]=pdist([x,y,z],'euclidean')谢谢下次您只需编辑原始问题,添加代码即可。@user3220520,当您发表评论时,会有一个小帮助框,为您提供发布代码的正确语法。还有一个链接可以获得更多帮助。