Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Matlab图形用户界面中如何从datacursor中获取值_Matlab_Matlab Figure_Matlab Guide - Fatal编程技术网

在Matlab图形用户界面中如何从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

如何从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);
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)点击它并检查你想要的消息是否真的被显示。。。