Calling a cyclic function in App Designer

조회 수: 10 (최근 30일)
Doug Rilee
Doug Rilee 2018년 12월 5일
답변: Greg 2018년 12월 6일
How can I have a function called cyclically in App Designer?
I am creating a project that uses set_param to send a value to Similink from and get_param to get a value from Simulink back into App Designer.
For set_param the triggered events with a switch, knob or slider work great. I would like to diaplay model results real-time to the App Designer UI. Is it possible to have a function called cyclically within App Designer?
  댓글 수: 2
Doug Rilee
Doug Rilee 2018년 12월 5일
편집: Doug Rilee 2018년 12월 5일
Solutuon as provided by a collegue
I will post my project with this code soon.
Create a timer object as follows:
properties (Access = private)
timerObj % timer
end
% startUpFcn
app.timerObj = timer('TimerFcn'), @(~,~)getModelValues(app), 'Period', 0.5, 'ExecutionMode', 'fixedSpacing', 'BusyMode', 'drop');
start(app.timerObj);
Create a function like getModelValues(app) with the get_param code and it will be called cyclically as you specifiy with the period.
Kevin Chng
Kevin Chng 2018년 12월 6일
great to know this solution. Your colleague is awesome. In the past, i might create a while loop for it.

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

답변 (1개)

Greg
Greg 2018년 12월 6일
I can't give you actual code examples (every situation is different). But, a probable better approach than the timer in AppDesigner would be pass the appropriate handle into the Simulink model. Then, have the model update whatever graphics object you want in each iteration of the simulation.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by