Clear Filters
Clear Filters

Can I somehow use a variable from a pushbutton function to another pushbutton function

3 views (last 30 days)
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

Accepted Answer

Richard Burnside
Richard Burnside on 23 Jun 2023
Edited: Richard Burnside on 23 Jun 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".

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!