How to Alternate Between Two Different Graphs

So I'm plotting a graph and the direction field. Is there any way I can press a button and switch between the two graphs, also changing the title and axis labels?

 採用された回答

Image Analyst
Image Analyst 2016 年 2 月 16 日

0 投票

I don't know what "switch between the two graphs" means. Does it mean that you have two graphs and you want to swap them - left graph goes to the right and right graph goes to the left? Or you just want to make the current axes whatever it isn't now?
Anyway, to switch to a particular axes, use the axes() function
axes(handles.axes1);
title('Now on axes1');
xlabel('x1');
ylabel('y1');
axes(handles.axes2);
title('Now on axes2');
xlabel('x2');
ylabel('y2');

4 件のコメント

Krish Desai
Krish Desai 2016 年 2 月 16 日
Basically what I want to do is have one graph and then when I press a button another graph pops up. I don't know if that helps any, I saw my roommate doing it, but I forgot to ask him what he did to do that.
Image Analyst
Image Analyst 2016 年 2 月 16 日
Every time you call figure(), another figure window will popup. Then you can call plot(), bar(), scatter(), imshow() or whatever, and it will create an axes on the figure window and show whatever it is you're trying to show.
Krish Desai
Krish Desai 2016 年 2 月 16 日
So where do I put the figure() in the following:
plot(y,(.65*y)-(0.65*y.^2/6.1));
title('Graph of Rainbow Trout')
ylabel('Amount of fish (hundreds)')
xlabel('Time (days)')
hold on
f= @ (t,y) (.65*y)-(0.65*y.^2/6.1)-(((1.2*(y^2))/(1+(y^2))));
dirfield(f,0:1:6, 0:.1:2)
title 'Direction Field of Rainbow Trout'
Image Analyst
Image Analyst 2016 年 2 月 16 日
What does dirfield() do? Does it popup another figure automatically, or does it plot something to the current axes, or does it do something else? Does it put a quiver-like array of vectors over an existing image? If it pops up a new figure, replace "hold on" with "figure".

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by