display extra value in datacursor

3 ビュー (過去 30 日間)
Joanie
Joanie 2014 年 6 月 11 日
回答済み: Zikobrelli 2014 年 6 月 12 日
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.

回答 (1 件)

Zikobrelli
Zikobrelli 2014 年 6 月 12 日
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,

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by