Is it possible to display multiple figures next to each other

4 ビュー (過去 30 日間)
Arthur
Arthur 2020 年 5 月 4 日
回答済み: Mehmed Saad 2020 年 5 月 4 日
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.

採用された回答

Mehmed Saad
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 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by