From: Indrek Morell on
Hi everyone!

Can anyone tell me, is there any possibility to get the Data Cursor to read discontinuous axis data? A mean using for example 'XData' function to aquire new tick values from an array. It works well with continuous array (5;6;7;8;9;10 ... etc), but can it work with something like this (5; 10; 7; 9; 8; 6.... etc).. right now the 'XData' function replaces ticks with values from 5 to 6 (continuous from first value to the last from specified array). I´d really like it to be able to read ALL the values in corresponding sequence.

Any suggestions?
From: Steven Lord on

"Indrek Morell" <IndrekM80(a)hot.ee> wrote in message
news:hji5de$tf$1(a)fred.mathworks.com...
> Hi everyone!
>
> Can anyone tell me, is there any possibility to get the Data Cursor to
> read discontinuous axis data? A mean using for example 'XData' function to
> aquire new tick values from an array. It works well with continuous array
> (5;6;7;8;9;10 ... etc), but can it work with something like this (5; 10;
> 7; 9; 8; 6.... etc).. right now the 'XData' function replaces ticks with
> values from 5 to 6 (continuous from first value to the last from specified
> array). I�d really like it to be able to read ALL the values in
> corresponding sequence.
>
> Any suggestions?

So you've changed the X tick labels and you'd like the data cursor to
display the modified tick labels?

plot(1:10, 1:10);
set(gca, 'XTickLabel', {'10','1','9','2','8','3','7','4','6','5'})

If so, write a custom update function. See the section titled "Customizing
Data Cursor Text" on the following documentation page:

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f4-44221.html#f4-44236

[Note that this is the documentation for the most recent version of MATLAB;
if you're using an older version, not all the functionality described may be
available in your installation.]

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ




From: Indrek Morell on
Sorry to bother you but i guess i´m just too stupid for this.

Lets say, that i have 10x10 array of random values, and i want the X-axis values to be like defined in array "X".. and Y-axis like Y.

S=randn(10);
X=[1 5 0 9 6 7 8 4 2 3];
Y=[2 5 9 0 4 7 8 6 1 3];
h=imagesc(S);
set(gca,'XTickLabel',X);

Everything is going fine up to this point, but can you help me, how should my saved custom cursor function look like? I´d like it to display the axis positions according to arrays X and Y and also the values for each square (Z-axis??) - that is for example on 4th position on 2nd row it should display something like this: Y=9, Y=5, Z=randn (value from array)...

Thanks!

Default is,

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