Hello, I want to be able to display the name of the dot in a graph according to the vector position.
my code is
functionfig = figure;a = [1 2 3 4 5]b = [2 3 4 5 6]name{1} ='one';name{2} ='two';name{3}='tree';name{4}='four';name{5}='five';scatter(a, b, 'filled')dcm_obj = datacursormode(fig);set(dcm_obj,'UpdateFcn',@myupdatefcn)endfunction txt = myupdatefcn(empt,event_obj)pos = get(event_obj,'Position');nameNumber = 'WantCorrectNameHere';txt = {['X: ',num2str(pos(1))],... ['Y: ',num2str(pos(2))],... nameNumber};end
So I want to have access to the right name at the selected position for exemple for a(1);b(1) -> name{1}
Best Answer