Friday, 13 September 2013

MATLAB linking figure for simultaneous zooming and panning

Sometime back I have written a Matlab GUI, which allows you select variables from your work space and plot them in linked figures so that when you pan and zoom, other figures zoom automatically. Lately I have received a lot of request to share that GUI with other but unfortunately I am unable to do so as I developed it for some research works and I am not allowed to distribute it. But, I am going to share you a function which does that linking.

To use that function, download it from here. There is a test.m for testing purpose as well.

%first image
Im1 = imread('cameraman.tif');
% show first figure
imshow(Im1)
% threshold image
Im2 = Im1>50;
%show second image in another figure
figure,
imshow(Im2);
% then call linkaxes_shailesh ()
% remember that matriz size must be same</code>

Put it in a safe place in a folder, set path in Matlab to that folder so that the function is available in every Matlab session ( file> set path). Open two or more figure you want to link in but bear in mind that the variables used in the figures must of same size i.e. it should have same number of rows and columns. After that, call that function by typing linkaxes_shailesh in your command line or you can even call it within one of your m file or function files by linkaxes_shailesh ()  and viola, your figures will be linked.  Its simple as that, don’t believe? Try out yourself. Someone said rightly ‘ Seeing is believing’. I hope you find it useful.

<iframe width="560" height="315" src="//www.youtube.com/embed/QhqnGdk2yQU?list=UUHQMpdmbYQPJxqsnKuz9DUw" frameborder="0" allowfullscreen></iframe>