How can I control two axes over a single slider?
Show older comments
I have the above code:
handles.SliderFrame = uicontrol('Style','slider','Position',[60 20 400 50],'Min',1,'Max',NumFrames,'Value',1,'SliderStep',[1/NumFrames 2/NumFrames],'Callback',@XSliderCallback);
handles.SliderFrame2 = uicontrol('Style','slider','Position',[60 20 400 50],'Min',1,'Max',sno_s,'Value',slice2,'SliderStep',[1/(sno_s-1) 10/(sno_s-1)],'Callback',@XSliderCallback);
handles.Text1 = uicontrol('Style','Text','Position',[180 420 60 30],'String','Current frame');
handles.Edit1 = uicontrol('Style','Edit','Position',[250 420 100 30],'String','1');
function XSliderCallback(~,~)
handles = guidata(gcf);
%// Here retrieve MyMatrix using getappdata.
MyMatrix = getappdata(hFig, 'MyMatrix');
idx = round((get(handles.SliderFrame, 'Value')));
idx2 = round((get(handles.SliderFrame2, 'Value')));
set(handles.Edit1,'String',num2str(idx));
set(handles.Edit1,'String',num2str(idx2));
filelist = handles.filelist;
frameindex = max(1, min(idx, NumFrames));
handles.frameindex = frameindex+1;
ff = filelist{frameindex};
I=dicomread(ff);
subplot(2,2,1)
image(handles.axes1, I(idx));
imshow(squeeze(I(:,:,idx,:)));
[~, basename, ~] = fileparts(ff);
title( basename);
subplot(2,2,2)
image(handles.axes2, im3(idx2));
imshow(squeeze(im3(:,:,idx2,:)),'XData',[1 592], 'YData',[1 481])
subplot(2,2,3)
image(handles.axes3, im4(idx));
guidata(hFig,handles);
drawnow()
end
It is working. The problem is that I need to modify it somehow that it can alter both axes1 and axes2 the images on them. As it is now, it shows a static image on axes1 and it moves the image in axes2.
I know how to modify it to move the images in axes1, but that means I have to delete several lines for axes2. How can I do it work for both axes at the same time?
1 Comment
Stelios Fanourakis
on 18 Jun 2018
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!