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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by