Effacer les filtres
Effacer les filtres

Run code with two sections - app designer

1 vue (au cours des 30 derniers jours)
Shahar ben ezra
Shahar ben ezra le 13 Juil 2021
Commenté : Debt le 16 Juil 2021
I made an example of a problem I have.
I wrote a code with 2 sections
When I press RUN_1 it calculates X * Y (this is works)
When I press RUN_2 he does not remember the value XY so he does not compute me XYZ (this is not works :( )
Thanks!
  1 commentaire
Debt
Debt le 16 Juil 2021
you can add private properties to solve this problem

Connectez-vous pour commenter.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 13 Juil 2021
Modifié(e) : Cris LaPierre le 14 Juil 2021
You need to keep in mind variable scope. All your callbacks are functions. Variables created inside a function are lost once the function terminates. The way around this in app designer is to create an app property to capture these values. You can then access them using the app.varName syntax.
See here for more.
  3 commentaires
Shahar ben ezra
Shahar ben ezra le 15 Juil 2021
Hello again
Unfortunately I could not make it work
What should I call the function?
Is it possible for you to give me an example?
tnx
Cris LaPierre
Cris LaPierre le 15 Juil 2021
You are not creating a function. You are creating a propery. There is no need to change the name. Use XY. The only change is, instead of using XY, you would now use app.XY.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by