How to declare a global variable in Startup function of matlab app.designer

123 Ansichten (letzte 30 Tage)
I want to declare a global variable in matlab app designer's startup function in order to use it continuously through the app's code.
Specifically, I want to declare value1 as a global variable
I have tried that but it doesn't seems that works.
Thank you very much

Akzeptierte Antwort

Adam Danz
Adam Danz am 13 Jan. 2021
Bearbeitet: Adam Danz am 14 Jan. 2021
Do not use global variables, especially in AppDesigner.
Instead, declare a public or private property accessible anywhere within the app or outside of the app (for public properties).
  7 Kommentare
Adam Danz
Adam Danz am 14 Jan. 2021
Bearbeitet: Adam Danz am 14 Jan. 2021
You're not declaring the property correctly. Check out the "step-by-step guide" link in my answer. It shows you pictures of each step.
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras am 14 Jan. 2021
Thanks for your reply!
What I was doing wrong was that I was putting in the button callback:
app.editnum.Value=value1; %INCORRECT
Instead of
app.editnum.Value=app.value1; %CORRECT
Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by