0

I see there have been many questions about this topic, but I cannot seem to figure it out.

I want to move my slider, and update my image stack as I do so. I currently have it so that I can view the stack, by changing the left and right hand arrows. But, as I drag the slider, I would like to drag through the stack and continuously update the axes.

% --- Executes on slider movement.
function Slider_Callback(hObject, eventdata, handles)

imshow(handles.FloatArray(:,:,get(handles.Slider,'Value'))); % Update axes when pressing
axis(handles.Axes, 'on');                                    % left & right slider buttons

I believe (from what I have read) I need to implement an addlistener? I am unsure how to do this, and the MATLAB help page leaves me more confused.

Any guidance would be much appreciated.

Shinobii
  • 2,401
  • 5
  • 24
  • 39

1 Answers1

1

Nothing beats a good example

fh = figure;
s = uicontrol('style','slider','parent',fh,'callback',@Slider_Callback);
addlistener(s,'Value','PostSet',@(s,e)Slider_Callback(fh));
Mercury
  • 1,886
  • 5
  • 25
  • 44
  • Thanks for your reply! Interesting; I tried simply copying this into my code, and when I let go of the mouse button, a new figure pops up with the corresponding image. Please forgive my ignorance, is it the fh I need to change (I tried to change it to my Axes handle (handle.Axes) but it did not like that)? – Shinobii Feb 12 '14 at 03:31