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

5 vues (au cours des 30 derniers jours)
Rashi Mehrotra
Rashi Mehrotra le 4 Fév 2022
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 commentaires
Jan
Jan le 9 Fév 2022
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 le 9 Fév 2022
How does the user define the variable and in what workspace?

Connectez-vous pour commenter.

Réponses (1)

Nivedita
Nivedita le 14 Nov 2023
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.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by