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

11 次查看(过去 30 天)
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?

请先登录,再进行评论。

回答(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 中查找有关 Develop Apps Using App Designer 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by