在Matlab图形用户界面中如何从datacursor中获取值
如何从datacursor获取游标位置的值?这是我的密码在Matlab图形用户界面中如何从datacursor中获取值,matlab,matlab-figure,matlab-guide,Matlab,Matlab Figure,Matlab Guide,如何从datacursor获取游标位置的值?这是我的密码 filename = handles.loadDataName; x=importdata(filename,' ',indexend); fid = fopen(filename,'r'); A = textscan(fid,'%f%f','Delimiter',' ','headerLines',indexstart); data = cat(2,A{:}); time = data(:,1); c1 = data(:,2); plo
filename = handles.loadDataName;
x=importdata(filename,' ',indexend);
fid = fopen(filename,'r');
A = textscan(fid,'%f%f','Delimiter',' ','headerLines',indexstart);
data = cat(2,A{:});
time = data(:,1);
c1 = data(:,2);
plot(handles.axes_grafik,time,c1)
grid on;
dcm = datacursormode(gcf);
datacursormode on;
set(dcm, 'updatefcn', @myfunction)
function output_txt = myfunction( ~,event_obj)
dataIndex = get(event_obj,'DataIndex');
pos = get(event_obj,'Position');
output_txt = {[ 'Time: ',num2str(pos(1),5)] .....,
['Amplitude: ',num2str(pos(2),5)]};
当我试图修改函数输出_txt
以将pos(1)和pos(2)放入全局变量时,我在图中得到一个错误,上面写着“自定义数据提示字符串函数中的错误”
我想检索pos(1)和pos(2)以在editbox中显示它。有没有办法做到这一点?谢谢
[x,y]=ginput
此命令将允许您按任意次数单击您的图形,直到您按enter键,然后返回xy坐标。您是否在调试模式下运行了
myfunction
,并检查它是否正常工作?“错误消息”通常是正确的-在myfunction
。。。例如,附加一个disp(output_txt)代码>点击它并检查你想要的消息是否真的被显示。。。