Matlab合并多個.fig檔案

來源:互聯網
上載者:User

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 figureax2 = gca; % get handle to axes of figureh3 = openfig('3.fig','reuse');ax3 = gca;h4 = openfig('.4.fig','reuse');ax4 = gca;h5 = openfig('5.fig','reuse'); % open figureax5 = gca; % get handle to axes of figureh6 = openfig('6.fig','reuse'); % open figureax6 = gca; % get handle to axes of figureh7 = figure; %create new figures1 = subplot(2,3,1); %create and get handle to the subplot axess2 = subplot(2,3,2);s3 = subplot(2,3,3); %create and get handle to the subplot axess4 = subplot(2,3,4);s5 = subplot(2,3,5); %create and get handle to the subplot axess6 = subplot(2,3,6);fig1 = get(ax1,'children'); %get handle to all the children in the figurefig2 = get(ax2,'children');fig3 = get(ax3,'children'); %get handle to all the children in the figurefig4 = get(ax4,'children');fig5 = get(ax5,'children'); %get handle to all the children in the figurefig6 = get(ax6,'children');copyobj(fig1,s1); %copy children to new parent axes i.e. the subplot axescopyobj(fig2,s2);copyobj(fig3,s3); %copy children to new parent axes i.e. the subplot axescopyobj(fig4,s4);copyobj(fig5,s5); %copy children to new parent axes i.e. the subplot axescopyobj(fig6,s6);



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.