2017-09-27 38 views
0

在群集上完成了几次模拟,每个模拟都保存了一个图形,我想将这些图形组合成一个图形。将数字与子图组合到一个图中

为了方便,假设我们有两个数字:

x = 0:0.01:.2; 

subplot(1,3,1) 
plot(x,sin(x)) 
legend('sin(x)') 

subplot(1,3,2) 
plot(x,cos(x)) 
legend('cos(x)') 

subplot(1,3,3) 
plot(x,tan(x)) 
legend('tan(x)') 

x = 0:0.01:.2; 

subplot(1,3,1) 
plot(x,x,'r') 
legend('x') 

subplot(1,3,2) 
plot(x,1-x.^2/2,'r') 
legend('1-x.^2/2') 

subplot(1,3,3) 
plot(x,x,'r') 
legend('x') 

保存为figure1.figfigure2.fig。我现在想要将这两幅地块合并成一幅带有三幅小插图的图,这两幅图的颜色和传说都是一样的。是否有捷径可寻?

回答

2

Open both the figurescopy the objects其中一个数字。

hf1 = openfig('figure1.fig'); 
hf2 = openfig('figure2.fig'); set(hf2, 'Visible', 'off'); 

for k=1:numel(hf1.Children) 
    copyobj(hf2.Children(k).Children, hf1.Children(k)); %Copying objects to figure1 
end 

结果为所提供的样本数据是:

output
的曲线可能太相似应注意这是由于所提供的样本数据本身。

0

从图形菜单文件 - >生成代码...,您可以生成代码来创建图形。然后你可以根据你的需要修改它(子图索引和位置)与另一个图形组合。

我没找到一个通过生成代码的命令。

相关问题