Effacer les filtres
Effacer les filtres

Geting a varible defined in AppDesigner into a script

1 vue (au cours des 30 derniers jours)
Jo Bremer Balestracci
Jo Bremer Balestracci le 12 Oct 2020
Modifié(e) : Mario Malic le 12 Oct 2020
Using appdesigner I have developed a GUI that runs pretty good. I now want to take some variables that are defined in the app code and use them in a script I am developing. How do I do this? This is a function that is in the app designer and I want to use "NewInterval" in my script.
methods (Access = public)
function WhatIntervalSelected (app, ~)
if app.Interval1Button.Value == true;
NewInterval =1;
elseif app.Interval2Button.Value == true
NewInterval =2 ;
elseif app.Interval3Button.Value == true;
NewInterval =3;
elseif app.Interval4Button.Value == true
NewInterval =4;
elseif app.Interval5Button.Value == true
NewInterval =5;
else
NewInterval = 6;
end
end
How do I get NewInterval into my MATLAB Script?

Réponse acceptée

Mario Malic
Mario Malic le 12 Oct 2020
Modifié(e) : Mario Malic le 12 Oct 2020
You have few options, depending on the complexity of your app, I could suggest you to get the app instance in your script.
Set a Tag, or a unique name for your app in Component Browser, under UIFigure - Identifiers, and get its handle this way:
% in script
app = get(findall(0, 'Tag', 'AppUIFigure'), 'RunningAppInstance');
% ^^^^^^^^^^^
Set your NewInterval as a property, and just call it within your script as
app.NewInterval
You can also convert your script to function that you pass the NewInterval property (must define it that way too), but this is a bit of a hassle and not necessary.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by