필터 지우기
필터 지우기

Run pushbutton automatically as soon as the GUI is visible without pressing the pushbutton

조회 수: 1 (최근 30일)
I want to run my pushbutton automatically as soon as the GUI is visible. And dont have to press the pushbutton in order to start the pushbutton. I only want the pushbutton to be started once. Can i get any help? Im new to MATLAB and i have searched but cannot find my answer.
Thankyou in advance.

채택된 답변

Walter Roberson
Walter Roberson 2019년 11월 14일
In the OpenFcn callback, create a timer object configured for a single execution, and have the callback for the timer object be a call to the name of the callback for the pushbutton, passing in the handle of the pushbutton, then [], and then the handles variable. But do it like this:
handles.push_timer = timer(... various arguments ...);
guidata(hObject, handles); %store a copy of handles complete with the push_timer
handles.push_timer.TimerFcn = @(hObject, event) YourGUI_pushbutton1_Callback(handles.pushbutton1, [], handles);
start(handles.push_timer)
That is, do not set the TimerFcn callback to refer to handles until after you have already stored the timer object in handles. The timer() function permits you to configure TimerFcn as an option at the time you create the timer, but do not do that. If you do that, then the value of handles that makes it into the callback will not include the timer object and you would risk the timer being deleted before it gets used.

추가 답변 (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