Effacer les filtres
Effacer les filtres

How to reduce the rate MATLAB attempts to execute a function in the Value Changing callback

1 vue (au cours des 30 derniers jours)
Hello. I am writing an app in app designer and a part of it requires Matlab to graph a function. As I move a slider, I want the graph to change, so I used the 'Value changing' callback, but I realized that the calculation is taking too long for Matlab to keep up with. Is there a way for me to specify for Matlab to try to regraph only 10 times a second?
(I have tried to reduce lag time by creating a matrix that contains the values on startup, so all that the callback is doing is indexing the matrix, assigning values to X and Y, and then graphing)
  1 commentaire
Walter Roberson
Walter Roberson le 1 Fév 2020
Modifié(e) : Walter Roberson le 1 Fév 2020
One technique is to keep track of the last time the function was invoked, and if it was less than 1/frequency ago then return (without recording the time)

Connectez-vous pour commenter.

Réponse acceptée

Alexander Larking
Alexander Larking le 1 Fév 2020
Walter Roberson gave me a great answer in the comments.
I set tic to start a timer when the app is launced, and toc to measure how long it had been since it was last executed. Make sure that you're using event.Value to get the value of the thing that is changing - app.slider.Value will not work!!!!

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by