Timer Interrupt in App Designer

조회 수: 26 (최근 30일)
Hossam Alzomor
Hossam Alzomor 2019년 10월 21일
댓글: Guillaume 2019년 10월 21일
Hi,
I am trying to implement a timer interrupt in app designer,
I did the following
  • define t in properties
  • init timer in startupFcn
app.t=timer;
app.t.TimerFcn = @DisplayFPS;
app.t.Period =1;
app.t.ExecutionMode = 'fixedRate';
  • implement timer callback function inside private methods
function DisplayFPS(app,mTimer,~)
framerate= app.framescount/app.framestime;
message = sprintf("Frame rate = %f f/s",framerate);
app.ResultTextArea.Value = [message;app.ResultTextArea.Value];
app.framescount = 0;
app.framestime = 0;
end
but I get the following error when I start
Error while evaluating TimerFcn for timer 'timer-2'
Undefined function 'DisplayFPS' for input arguments of type 'timer'.
How could I overcome this problem?

채택된 답변

Guillaume
Guillaume 2019년 10월 21일
app.t.TimerFcn = @app.DisplayFPS; %<--DisplayFPS is a method of the app, so must be called with app argument
  댓글 수: 2
Hossam Alzomor
Hossam Alzomor 2019년 10월 21일
Thanks for reply
after doing modification I get another error
Error while evaluating TimerFcn for timer 'timer-1'
Matrix dimensions must agree.
Guillaume
Guillaume 2019년 10월 21일
So, it's calling your callback now, but there's a bug in your callback.
Possibly app.framescount or app.framestime is not scalar.
We'd need to see the full error message to be sure. In any case, that's nothing to do with your original question.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by