フィルターのクリア

How to designate an axes for plot in the GUI environment with a timer

2 ビュー (過去 30 日間)
Feng
Feng 2016 年 12 月 5 日
コメント済み: Walter Roberson 2016 年 12 月 6 日
I have two GUI figures, with one having an axes in to plot using 'plot' in a time function. However, when the second GUI window opens, the plot will get to the 2nd GUI, rather than staying in the 1st figure. If I use a command like 'openfig', it will generate an error in the timer function.
Any suggestions?
Thanks!
  1 件のコメント
David Barry
David Barry 2016 年 12 月 6 日
Have you created an axes handle and are you using it as the first input to plot? Can you share your code?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 12 月 6 日
When you create the timer callback, pass the axes handle as one of the parameters to it.
ax = handles.axes3;
t = timer('Callback', @(src, event) MyTimerCallback(src, event, ax), ....);
function MyTimerCallback(src, event, ax)
plot(ax, ....)
  2 件のコメント
Feng
Feng 2016 年 12 月 6 日
Thanks Walter, for trying to help me!
Here is the related part of the code I changed based on your suggestion:
ax = handles.TG_Plot
b = timer;
b.ExecutionMode='FixedRate';
b.period = 5;
b.name = 'PowerAndCurrent';
b.TimerFcn = @(src, event) PowerCurrentRead(src, event, ax);
b.StartDelay = 0.3;
function PowerCurrentRead(src, event, ax)
plot(ax, w(1,:), w(2,:),'r','Linewidth',2)
The TG_Plot is the Axes I generated in the gui environment where I intended to plot.
It starts to plot on this Axes. But as soon as I start working on the second gui figure, the plot jump to the new gui, and will come back after I close the 2nd gui.
Thanks,
Feng
Walter Roberson
Walter Roberson 2016 年 12 月 6 日
That should not happen with that code, not unless somehow the Parent of handles.TG_Plot gets set to the new figure.
By the way, where is PowerCurrentRead getting w from?

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

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by