码迷,mamicode.com
首页 > 其他好文 > 详细

Matlab合并多个.fig文件

时间:2015-07-24 06:56:24      阅读:596      评论:0      收藏:0      [点我收藏+]

标签:matlab subplot   .fig   合并多个.fig文件   合并.fig   subplot   

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
ax5 = gca; % get handle to axes of figure
h6 = openfig('6.fig','reuse'); % open figure
ax6 = gca; % get handle to axes of figure


h7 = figure; %create new figure
s1 = subplot(2,3,1); %create and get handle to the subplot axes
s2 = subplot(2,3,2);
s3 = subplot(2,3,3); %create and get handle to the subplot axes
s4 = subplot(2,3,4);
s5 = subplot(2,3,5); %create and get handle to the subplot axes
s6 = subplot(2,3,6);


fig1 = get(ax1,'children'); %get handle to all the children in the figure
fig2 = get(ax2,'children');
fig3 = get(ax3,'children'); %get handle to all the children in the figure
fig4 = get(ax4,'children');
fig5 = get(ax5,'children'); %get handle to all the children in the figure
fig6 = get(ax6,'children');


copyobj(fig1,s1); %copy children to new parent axes i.e. the subplot axes
copyobj(fig2,s2);
copyobj(fig3,s3); %copy children to new parent axes i.e. the subplot axes
copyobj(fig4,s4);
copyobj(fig5,s5); %copy children to new parent axes i.e. the subplot axes
copyobj(fig6,s6);



版权声明:本文为博主原创文章,未经博主允许不得转载。

Matlab合并多个.fig文件

标签:matlab subplot   .fig   合并多个.fig文件   合并.fig   subplot   

原文地址:http://blog.csdn.net/vernice/article/details/47034465

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!