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

조회 수: 124 (최근 30일)
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

채택된 답변

Adam Danz
Adam Danz 2021년 1월 13일
편집: Adam Danz 2021년 1월 14일
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
Adam Danz
Adam Danz 2021년 1월 14일
편집: Adam Danz 2021년 1월 14일
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 2021년 1월 14일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by