Can I somehow use a variable from a pushbutton function to another pushbutton function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rares Pop
le 23 Juin 2023
Commenté : Rares Pop
le 23 Juin 2023
Xp_1=0;
Yp_1=0;
Xp_4=0;
Yp_4=Y_val;
Xp_3=X_val;
Yp_3=Y_val;
Xp_2=X_val;
Yp_2=0;
Xp=[Xp_1,Xp_2,Xp_3,Xp_4];
Yp=[Yp_1,Yp_2,Yp_3,Yp_4];
hold(app.UIAxes_10,"on");
plot(app.UIAxes_10,Xp,Yp);
[xi,yi]=getpts(app.UIAxes_10);
p = [xi yi];
I want to use [xi,yi] in another pushbutton function
0 commentaires
Réponse acceptée
Richard Burnside
le 23 Juin 2023
Modifié(e) : Richard Burnside
le 23 Juin 2023
Yes you can but you will have to store the data. A decent choice is the UserData field of the gui figure, root object or guidata.
At the time you create the gui figure you could place a tag:
hf = uifigure('HandleVisibility','on',...
'Name','Flight Data Analysis', ...
'Toolbar','none','MenuBar','none','Resize','off',...
'Color',[1 1 1],...
'Tag','MainFig');
and then within a button callback function find the object and assign or read data from the UserData field:
mf = findobj('Tag','MainFig');
data = mf.UserData;
Other places to store data are "guidata" or using the UserData field of the root object with "groot".
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks 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!