display extra value in datacursor

19 vues (au cours des 30 derniers jours)
Joanie
Joanie le 11 Juin 2014
Is there a way to add other values to the datacursor? So besides x and y.
I have an array with x and y values and a value d. Now I like to see value d of the selected point in the datacursor.

Réponses (1)

Zikobrelli
Zikobrelli le 12 Juin 2014
Data cursor has a callback function that can be found like this: on your plot: 1)click on the data cursor 2)Right click on the plot 3)Edit text Update function
You should get smthg like this: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ù function output_txt = myfunction(obj,event_obj) % Display the position of the data cursor % obj Currently not used (empty) % event_obj Handle to event object % output_txt Data cursor text string (string or cell array of strings).
pos = get(event_obj,'Position'); output_txt = {['X: ',num2str(pos(1),4)],... ['Y: ',num2str(pos(2),4)]};
% If there is a Z-coordinate in the position, display it as well if length(pos) > 2 output_txt{end+1} = ['Z: ',num2str(pos(3),4)]; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4)you can add more info/values and then save function to workspace
Cheers,

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by