Pre-built functions suddenly became undefined in app designer?
조회 수: 2 (최근 30일)
이전 댓글 표시
In my application I have buttons that are changing color on press by means of code like this:
function Button_2Pushed(app, event)
app.user_button_sequence = [app.user_button_sequence 2];
stop(timerfind)
but2_timer = timer;
but2_timer.StartDelay = 1;
but2_timer.StartFcn = @(~,thisEvent) toggleColorOn(app,2);
but2_timer.TimerFcn = @(~,thisEvent) toggleColorOff(app,2);
start(but2_timer)
end
And this has been working perfectly fine as I have been developing it.
I have saved, closed, and opened this many times before, and it was fine each time. Today however, upon trying to make the button change color, it tels me that 'stop' is an undefined function for input arguments of type 'double'. If commented out, it says the same thing about 'start' but for objects (which the timer is).
What happened that this issue is suddenly popping up? I searched for other issues like this and ran into comments about running the code:
restoredefaultpath
rehash toolboxcach
but this hasn't fixed anything.
Can anyone share some insight into what happened and why it suddenly stopped working?
댓글 수: 0
답변 (1개)
Walter Roberson
2023년 3월 17일
if timerfind() returns empty then it is [] that it returns rather than an empty array of class timer. And stop([]) does not work. You should be using something like
existing_timers = timerfind();
if ~isempty(existing_timers); stop(existing_timers); end
But are you sure you want to stop all other timers and create a new timer, leaving the other ones existing but in stopped state ??
댓글 수: 7
Walter Roberson
2023년 3월 29일
It did eventually end, and does appear to have created all the timers. But timerfind() and timerfindall() are reporting empty even though the timers have ObjectVisibility on
Jeremy Hughes
2023년 3월 30일
Thanks @Walter Roberson, This is a great analysis. There's no hard limit on the number of timers, but it looks like you've hit the practical limits of how many you can create.
I'm surprised timerfind doesn't return anything. I'll look at that one.
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!