How can i get the value of cursor position from datacursor? here's my code
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)]};
When i tried to modified function output_txt to get pos(1) and Pos(2) into global variable, i got an error on figure which says 'error in custom datatip string function'
I want to retrieve pos(1) and Pos(2) to display it in editbox. Is there any way to do this? Thanks
myfunctionin debug mode and checked that it works? The "error message" usually is correct - something probably went wrong inmyfunction... E.g. append adisp(output_txt);to it and check that the message you want really gets displayed... - sebastian