So, if I call the function with "app" as an argument, as if "app" is a structure, I should be able to refer to all the variables that are defined in the Appdesigner code as app.var1, app.var2.... etc within the function?
How do I access AppDesigner variables in a function that I write and call?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ranjan Sonalkar
le 27 Jan 2022
Commenté : Jon
le 28 Jan 2022
I am calling a function that I wrote from a GUI I designed with Appdesigner. I want to use many variables such as app.* in that function. I would rather not define a huge number of input variables for the function. I have used global variables in the past, use of global variables is not recommended by Matlab and teh global declaration gets a forbidding red underline. Is there an easy and compact way to access all the app.* variables functions called by the GUI designed in appdesigner?
0 commentaires
Réponse acceptée
Ranjan Sonalkar
le 27 Jan 2022
3 commentaires
Jon
le 28 Jan 2022
You can also call any public methods of app, so if your app had a public function, myAppFun
function result = myAppFun(app,x)
...
end
then inside of your function, myFun that takes app as an argument you could call it using for example
function myFun(app,x)
y = app.myAppFun(x)
Plus de réponses (1)
Jon
le 27 Jan 2022
Modifié(e) : Jon
le 27 Jan 2022
So I'm understanding that you have written a function and want to call it from within your appdesigner app. You then want this function to have access to the variables within the app. If so, I think you can get what you want simply by passing app as an argument to your function.
0 commentaires
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!