Timer - plotting graph to axe in current figure
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, i have problem. I am passing parameters to timer Fcn like this:
%gui openingfcn (not the whole code) + nested timer function in it
myfigure = gcf;
guidata(myfigure,handles);
t = timer;
t.Period = 2;
t.ExecutionMode = 'fixedRate';
t.TimerFcn = @mytimer_cb;
t.BusyMode = 'drop';
t.UserData = myfigure;
start(t);
function mytimer_cb(h,~) % here starts timer nested function
hObject = h.UserData;
handles = guidata(hObject);
Then (lower in the timer Fcn) I want to plot graph in current figure like this:
axes(handles.axes_realbezmod);
h = plot( bezmod_x, bezmod_y, 'ob' );
But the results looks like this (the graph is not in figure):
I tried findall(0,'type','figure'), I tried to set a parent, but it didn't work.
Do you have any other ideas?
Thanks
0 件のコメント
採用された回答
Adam
2016 年 4 月 7 日
編集済み: Adam
2016 年 4 月 7 日
Try the more explicit version which is always better to use:
h = plot( handles.axes_realbezmod, bezmod_x, bezmod_y, 'ob' );
If that doesn't work it should at least fail in some way other than just creating a new figure which may help diagnose the problem.
Looking again at your code though you seem to be calling your time callback with no arguments passed in whereas the function expects what I assume if a figure handle.
I haven't really used timer for anything but I assume you need more like:
t.TimerFcn = @() mytimer_cb( h );
assuming h is the handle you expect within your timer callback.
3 件のコメント
Adam
2016 年 4 月 7 日
Use the same technique. All these functions now accept an axes handle as their first argument in one of the function overloads so e.g.
xlabel( hAxes, 'SomeLabel' )
will explicitly apply the label to the given axes.
I used to uses the technique you use above until I kept running into unexpected (for me back then) issues with new axes getting created or things plotting to the wrong figure. This explicit method of telling it which axes to use avoids all that.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Specifying Target for Graphics Output についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!