Using a single figure frame for chasePlot used inside a loop

I have a while loop inside of which I have to use a plot and a chasePlot function.
The problem is, it comes up with a new window figure each time the loop runs. I somehow want a single frame which can be updated rather than each time making a new window and figure for it.
Anybody knows how to prevent a new figure in each loop so that one figure is there and that keeps on updating.

 採用された回答

Greg Dionne
Greg Dionne 2017 年 11 月 14 日

0 投票

If you have a handle to the axes you are using you can pass it to the 'Parent' property of the chasePlot when you construct it.
Something like:
hAxes = axes
chasePlot(scenario, 'Parent', hAxes)

3 件のコメント

Haroon
Haroon 2017 年 11 月 15 日
Thank you it works! But I used it like...
figure(1)
hAxes = axes;
chasePlot(passingCar,'Parent',hAxes);
Greg Dionne
Greg Dionne 2017 年 11 月 15 日
You'll probably want to do something like this (ultimately)
% set working figure to figure 1 (creating if it doesn't exist)
figure(1);
% get current axes (creating if it doesn't exist)
hAxes = gca;
% pass it to the chase plot.
chasePlot(passingCar,'Parent',hAxes)
If you call axes() you may end up creating a new one each time and just rendering it over the previous axes.
Haroon
Haroon 2017 年 11 月 16 日
Thank you. This works as well but I am using axes only because it gives me a good view of plot in plot. Though I don't know exactly how the output differs if I use
hAxes = gca;
or
hAxes = axes;
nor I know which one is better in my case.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

質問済み:

2017 年 11 月 13 日

コメント済み:

2017 年 11 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by