Can I somehow use a variable from a pushbutton function to another pushbutton function
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Richard Burnside
2023-6-23
编辑:Richard Burnside
2023-6-23
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".
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!