data cursor function for 3D slice

I need to make the data cursor on a 3D slice display value of the function being displayed; i.e. for slice(X,Y,Z,f,0,[],[]) make data cursor display value of f. Can you suggest a code to do that?
more example:
[X Y Z]=meshgrid([-2:.1:2],[-2:.1:2],[-2:.1:2]);
f=rand(41,41,41);
slice(X,Y,Z,f,0,[],[])

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 16 Apr. 2012

1 Stimme

Use datacursormode and set a your own updatefcn to display the value.
doc datacursormode
Provide us with a small example for more specific assistance.
More per example
function dcmmode_example
[X Y Z]=meshgrid([-2:.1:2],[-2:.1:2],[-2:.1:2]);
f=rand(41,41,41);
slice(X,Y,Z,f,0,[],[])
dcm_obj = datacursormode(gcf); %datacursor mode on
set(dcm_obj,'enable','on','updatefcn',{@updateMe X Y Z f}) %update, need X,Y,Z, f-values
function msg = updateMe(src,evt,X,Y,Z,f)
evt = get(evt); %what's happenin'?
pos = evt.Position; %position
fval = f(X==pos(1)&Y==pos(2)&Z==pos(3)); %where?
msg = num2str(fval); %create msg

Weitere Antworten (1)

A
A am 16 Apr. 2012

0 Stimmen

that worked... thanks
Total longshot, but is there a way to draw a line across the slice and plot the line profile? (i.e. have it open a new figure and plot values of f across that line)

5 Kommentare

Sean de Wolski
Sean de Wolski am 16 Apr. 2012
I don't see why not.
A
A am 17 Apr. 2012
how?
Sean de Wolski
Sean de Wolski am 17 Apr. 2012
Get the information (somehow similar to what I did) and then call another function that draws lines.
A
A am 18 Apr. 2012
let me rephrase the question... I need the user to be able to draw an arbitrary line on the slice figure and have matlab plot magnitude of f along that line.
Jan
Jan am 28 Apr. 2012
The question is not clear.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by