Controlling of two subplots by one slider

1 view (last 30 days)
Jan Kubicek
Jan Kubicek on 2 Sep 2016
Edited: Adam on 2 Sep 2016
I would like to kindly ask you about slider controlling of two subplots. I have the following variables containing 3D structures with five images:
a(:,:,1)=rand(300,300);
a(:,:,2)=ones(300,300);
a(:,:,3)=zeros(300,300);
a(:,:,4)=5*ones(300,300);
a(:,:,5)=zeros(300,300);
b(:,:,1)=zeros(300,300);
b(:,:,2)=ones(300,300);
b(:,:,3)=zeros(300,300);
b(:,:,4)=ones(300,300);
b(:,:,5)=zeros(300,300);
The variable a shall be placed into subplot(121), and variable b in subplot(122). I need to create one figure containing these two subplots, and one slider simultaneously controlling both subplots. I have done implementation for one series of images:
b(:,:,1)=zeros(300,300);
b(:,:,2)=ones(300,300);
b(:,:,3)=zeros(300,300);
b(:,:,4)=ones(300,300);
b(:,:,5)=zeros(300,300);
smin=1;
smax=5;
hsl = uicontrol('Style','slider','Min',smin,'Max',smax,...
'SliderStep',[1 1]./(smax-smin),'Value',1,...
'Position',[20 20 200 20]);
set(hsl,'Callback',@(hObject,eventdata) imshow(b(:,:,round(get(hObject,'Value')))))
I am unable to modify it for two subplots. Please, can anybody show me MATLAB implementation of the mentioned problem? Thank you very much in advance.

Answers (0)

Community Treasure Hunt

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

Start Hunting!