Producing subplots and then combine them into a figure later in MATLAB

前端 未结 4 1024
感动是毒
感动是毒 2020-12-01 16:59

My program produces small figures during the command cycle. Is there a way to just save these figures and then combine them in one figure later?

4条回答
  •  既然无缘
    2020-12-01 17:49

    I have an answer here as an example:

    h1 = figure(1)
    plot(1:10,'o-r');
    title('title');
    xlabel('xlabel');
    ylabel('ylabel');
    
    % Copy contents
    ch(1) = copyobj(gca,gcf);
    
    % Figure 2
    h2 = figure(2)
    plot(1:30,'o-r');
    title('title fig2');
    xlabel('xlabel');
    ylabel('ylabel');
    % copy contents
    ch(2) = copyobj(gca,gcf);
    
    figure(3)
    sh = subplot(1,2,1);
    clear axes
    p = get(sh,'position');
    ah = copyobj(ch(1),gcf);
    set(ah,'position',p);
    
    % Create axis template
    sh = subplot(1,2,2);
    clear axes
    p = get(sh,'position');
    ah = copyobj(ch(2),gcf);
    set(ah,'position',p);
    
    % Delete template
    % delete(sh);
    

提交回复
热议问题