Matlab提供了合并多个.fig文件的函数subplot(),通过调用subplot()函数可以将多个.fig合并为一个大的.fig文件。具体的工作原理是:subplot将画布划分为一个网格(grid),通过指定每个子fig文件的位置,将多个子fig合并为一个大的fig。该函数常用的方法如下:subplot(m,
n, p),m表示网格的行数,n表示网格的列数,p表示子fig文件在网格中的位置。比如m
= 3, n = 2, 不同p值如下图所示:
完整的代码如下所示:
h1 = openfig('1.fig','reuse');
ax1 = gca;
h2 = openfig('2.fig','reuse'); % open figure
ax2 = gca; % get handle to axes of figure
h3 = openfig('3.fig','reuse');
ax3 = gca;
h4 = openfig('.4.fig','reuse');
ax4 = gca;
h5 = openfig('5.fig','reuse'); % open figure