figureの複製方法について

35 views (last 30 days)
Naoki Hiraiwa
Naoki Hiraiwa on 3 Dec 2019
Edited: michio on 4 Dec 2019
例えば,図1にsin(x)をプロットして,図2にsin(x)とcos(x)をプロットしたい場合,
f1 = figure;
plot(x,sin(x));
f2 = figure;
plot(x,sin(x));
plot(x,cos(x));
のようにするのではなく,
f1を作成してsin(x)をプロットした後に,新しくfigureウインドウをつくりそこにf1にプロットされたものを貼り付けてからcos(x)を上書きする
といったことは可能でしょうか.
何か方法があれば教えてください.

Accepted Answer

Akira Agata
Akira Agata on 4 Dec 2019
copyobj関数が使えるかと思います。
以下は簡単なサンプルコードです。
x = linspace(0,4*pi);
figure
plot(x,sin(x))
ax = gca;
hFig = figure;
copyobj(ax,hFig) % Copy plot(s) in the previous figure
hold on
plot(x,cos(x))
  1 Comment
Naoki Hiraiwa
Naoki Hiraiwa on 4 Dec 2019
ありがとうございます.axをfigureにコピーすればプロットしたデータを複製できるのが盲点でした.ありがとうございます.

Sign in to comment.

More Answers (1)

Takumi
Takumi on 4 Dec 2019
copyobj関数を使うと良いと思います。 同様の質問がありますので以下を参考にしてください。 How to copy a figure in anothe figure?
  1 Comment
Naoki Hiraiwa
Naoki Hiraiwa on 4 Dec 2019
同じ質問があることに気づきませんでした.ありがとうございます.

Sign in to comment.

Categories

Find more on 2 次元および 3 次元プロット in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!