%% Synchronize Axis Limits
% Create a figure with three subplots and plot some data.

ax1 = subplot(3,1,1);
x1 = linspace(0,6);
y1 = sin(x1);
plot(x1,y1)

ax2 = subplot(3,1,2);
x2 = linspace(0,10);
y2 = 2*sin(2*x2);
plot(x2,y2)

ax3 = subplot(3,1,3);
x3 = linspace(0,12);
y3 = 4*sin(6*x3);
plot(x3,y3)

%
% Synchronize the x-axis and y-axis limits of each plot. Note that the new axes limits incorporate the old limits.

linkaxes([ax1 ax2 ax3],'xy')

% Panning or zooming into one of the subplots displays the same range of data in the other two subplots.
% To remove the linking, use linkaxes([ax1 ax2 ax3],'off').
% Copyright 2019 The MathWorks, Inc.