필터 지우기
필터 지우기

How to refresh a GUI data in a given time step, automatically?

조회 수: 4 (최근 30일)
Ali Y.
Ali Y. 2015년 9월 8일
댓글: Ali Y. 2015년 9월 9일
I have written a code that composes of several steps, i.e. several processing steps and then some GUI for visualization and plotting; steps are like: criterion 1, criterion 2, GUI control, and plot.
For repeating of the steps and showing results for different criteria, I need to make the GUI data (variables) get refreshed in a given time step, automatically. I want to embed the functionality within the GUI opening file. I used the following code, but it does not working. Maybe it's because of the 'Running' mode that is 'off'; but I don't know how to turn it on. Could somebody help me, please?
function my_gui_OpeningFcn
t = timer;
t.StartDelay = 0.1;
t.ExecutionMode = 'fixedRate'
t.Period = 1
t.TimerFcn = @(myTimerObj, thisEvent)refreshdata(hObject,handles);
start(t)
handles.timer = t
handles.output = hObject;
guidata(hObject, handles);
end

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 8일
Unless you are using a nested function that you have not displayed here, in your
t.TimerFcn = @(myTimerObj, thisEvent)refreshdata(hObject,handles);
neither hObject nor handles will be defined. Also, refreshdata() takes only a single parameter unless you supply the option 'caller'.
You have
function my_gui_OpeningFcn
if instead you had
function my_gui_OpeningFcn(hObject, event)
then you could use
t.TimerFcn = @(myTimerObj, thisEvent)refreshdata(hObject);
provided that the objects to be refreshed are all children of the GUI figure itself.
  댓글 수: 1
Ali Y.
Ali Y. 2015년 9월 9일
Thank you for your help Walter; applying the modification makes the code functioning; though, I found It will not be helpful, since my code only refresh the gui's data (objects and handles) without catching the updated work-space data. When I change the refreshdata (hObject,handles) to refreshdata (my_gui), It refresh the gui window that makes the window blink and untouchable.
Therefore, I think it is better, for me, to do the refresh outside of the gui and assign it to another callback function.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by