Azzera filtri
Azzera filtri

Why "timerfcn" do not recognize handles

6 visualizzazioni (ultimi 30 giorni)
I am using "timerfcn" to simulate a plot. code was working fine. But when i used it in gui, timerfcn stopped recognizing the defined variables; handles. how to pass handles form callback functions to timerfcn. I have labeled screen shorts to explain the error.
I defined handles L1,L2,L3,L4 and th in OpeningFcn to plot initial static graph
Then i used timerfcn inside Callback function of a "checkbox" labeled as "Animate" . It can be observed that handles are working fine outside timerfcn but are not recognized by the function.
What is recommended way of doing it? Is there any way to export these handles to base workspace so that timer function can work?
  4 Commenti
Sean de Wolski
Sean de Wolski il 15 Dic 2021
That just means the chosen architecture is bad. With component containers now allowing you to build modular components there's no reason an app ever needs to get that large. Pair that with model-view-control or a modified-model-view-control that does view/control in app designer and a data model class these problems are completely avoidable for large scale apps.
Walter Roberson
Walter Roberson il 15 Dic 2021
About 3 months ago, a number of us met with one of the managers for App Designer. The manager said nothing about modular components as being a potential cure for the performance problems that we were talking about.
The manager also had no resolution for the problem that the IDE for code that is outside of App Designer (such as a "data model class") is in a different window than the IDE for App Designer, making it a challenge to split the design in the way you are recommending.
Telling people that they have to refactor their design into smaller pieces to get around the fact that 5000 lines of code can take up to 20 minutes just to scroll is not an acceptable solution to the performance problems of App Designer.
There are two separate but related issues here:
  1. Performance of code built with App Designer. Mathworks has put a lot of effort into that, and in particular says that R2021b is significantly improved
  2. Performance and usability of App Designer itself for creating code. This continues to be a challenge.
Users have been posting saying that their team of programmers spent multiple months converting their projects to App Designer, and are finding that they have to convert back because App Designer is, in their experience, not workable for medium or large sized projects.
As far as I am concerned, App Designer is still only suitable for Prototype stage. That does not mean it does not have value, but blanket recommendations of "really should" switch to App Designer are rather premature in my opinion.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 14 Dic 2021
You are using a character vector as the timer function. When you use a character vector as a callback, then the character vector is evaluated in the base workspace. The base workspace does not have a variable named handles in it.
You should be switching to using an anonymous function as the callback.
Note: timer callbacks are not expected to return values. If you did code properly to be able to find the handles within a character vector callback, then Yes the base workspace A and th variable would be changed by the callback. That is not good design, though. If you really need to assign into the base workspace use assignin(). But consider other ways of storing values; http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

Più risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by