Is it possible to display multiple figures next to each other

조회 수: 7 (최근 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 CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by