Is it possible to display multiple figures next to each other
11 次查看(过去 30 天)
显示 更早的评论
I'm doing a project where it's usefull for me to compare figures and view them alone.
I was wondering wether it's possible to first generate the figures seperately and later in the code display them next to each other without having to recalculate everything.
I've found 2 different ways that I could do this, and written a small code to show how.
e.g. 1.
(This is the first way I'd do this)
y = [1 2 3 4 5 6];
x1 = 5*y;
figure()
plot(x1,y)
x2 = y.^2;
figure()
plot(x2,y)
figure()
tiledlayout(2,1)
ax1 = nexttile;
plot(x1,y)
ax2 = nexttile;
plot(x2,y)
e.g. 2.
(This is the second way I've found to do this)
y = [1 2 3 4 5 6];
x1 = 5*y;
figure()
plot(x1,y)
x2 = y.^2;
figure()
plot(x2,y)
figure()
plot(x1,y)
hold on
plot(x2,y)
hold off
Both of the above mentioned methods work, but for figures that take more time to generate, it's quite stupid to generate them twice, so I'm hoping that one of you can give me a faster way to plot at least one of the 2 above mentioned methods.
0 个评论
采纳的回答
Mehmed Saad
2020-5-4
You can use copy object
close all
y = [1 2 3 4 5 6];
x1 = 5*y;
figure()
a1=plot(x1,y);
x2 = y.^2;
figure()
a2=plot(x2,y,'r');
%
figure()
f=gca;
copyobj([a1 a2],f)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!