Matlab: Plots and Subplots - 如何让 Matlab 同时放大所有子图?

Matlab: Plots and Subplots - How do I make Matlab zoom into all the subplots simultaneously?

我有多个子图。当我放大第一个子图以查看某个数据集时,Matlab 不会缩放其余的子图。如何让 Matlab 同时放大所有子图?

subplot(2,1,1)
hold on
plot(Tim1.in,IA1.raw32SPC,'b-')
hold off

subplot(2,1,2)
hold on
plot(Tim1.in,IA1.cos,'r-*')
hold off

由于 x 变量相同,因此在这种情况下仅 link x 轴是有意义的。我添加了一些代码来创建 xy 变量,这样任何人都可以 运行 下面的代码。您还不必要地使用了 hold。

x = 1:10;
y1 = 3*x;
y2 = x.^2;
ax(1) = subplot(2,1,1);
plot(x, y1, 'b-')

ax(2) = subplot(2,1,2);
plot(x, y2, 'r-*')
linkaxes(ax, 'x')