目标:在Matlab指南中单击鼠标(使用“数据游标”工具)后,将(x,y)坐标写入文本文件(.txt)。
我试图弄清楚如何点击鼠标,选择数据光标工具,并以如下格式将坐标输出到文本文件中。我想要能够点击鼠标按钮无限次数,并将所有这些坐标写入一个文件。
写入文件格式
点号,x,y
步骤
当单击“数字化”时,__:
function digitize_Callback(hObject, eventdata, handles)
datacursormode on
!notepad.exe &发布于 2017-04-05 06:33:46
使用dcm_obj = datacursormode();和info_struct = getCursorInfo(dcm_obj);。例如,您可以在这样的循环中使用它们:
x = 0:0.1:1;
plot(x, x.^2, 'ro');
dcm_obj = datacursormode();
info_struct = [];
while true
info_struct = getCursorInfo(dcm_obj);
if ~isempty(info_struct)
fprintf('you chose point no. %d\n',info_struct.DataIndex);
fprintf('with coordinates: [x:%1.2f, y:%1.2f]\n\n',info_struct.Position(1),info_struct.Position(2));
break
end
pause(0.05)
end你会得到:
you chose point no. 9
with coordinates: [x:0.80, y:0.64]https://stackoverflow.com/questions/43215575
复制相似问题