how to define a user defined variable in matlab app without showing it in gui

조회 수: 12 (최근 30일)
Rashi Mehrotra
Rashi Mehrotra 2022년 2월 4일
답변: Nivedita 2023년 11월 14일
i have variables which are user defined, but some of them have to be shown in gui and some not, so how to initialize those user defined variable without being shown in gui made.
  댓글 수: 4
Jan
Jan 2022년 2월 9일
I don't get it. The code
a = 5
creates a variable, which is not shown automatically in a user defined GUI. So what exactly is the problem?
Adam Danz
Adam Danz 2022년 2월 9일
How does the user define the variable and in what workspace?

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

답변 (1개)

Nivedita
Nivedita 2023년 11월 14일
Hello Rashi,
I understand that you want to initialize user defined variables without being shown in the GUI made. In MATLAB App Designer, there are two types of properties you can define: public and private.
Public properties are accessible from outside the app and are shown in the GUI, while private properties are only accessible within the app and are not shown in the GUI.
You can use private properties to store variables that you don't want to show in the GUI. Here's an example of how you can define private properties:
properties (Access = private)
myVar1 = 1; % some default value
myVar2 = 'hi'; % some default value
end
You can then use these variables anywhere in your app by referring to them as "app.myVar1" and "app.myVar2".
If you want to initialize these variables with user-defined values, you can do so in the startup function of your app:
function startupFcn(app, userVar1, userVar2)
app.myVar1 = userVar1;
app.myVar2 = userVar2;
end
In this example, "userVar1" and "userVar2" are the user-defined values that you pass to your app when you run it. You can pass these values like this:
myApp(userVar1, userVar2)
In this line, "myApp" is the name of your app, and "userVar1" and "userVar2" are the user-defined values for your variables.
I hope this helped!
Regards,
Nivedita.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by