Problem in CurrentFigure or in gcf
1 次查看(过去 30 天)
显示 更早的评论
Hi,
this is my code after pressing pushbutton:
h=findobj(0,'Type','figure','Tag','figure1');
UserData=get(h,'UserData');
h=figure;
set(gcf, 'units','normalized','outerposition',[0 0 1 1],'name','a','numbertitle','off'); % Maximize figure.
g=plot(t,x);
UserData.d=7;
set(h,'UserData',UserData);
guidata(hObject, handles);
Why I do not have UserData.d=7 in others pushbuttons? Thank you
0 个评论
采纳的回答
Image Analyst
2014-1-16
Use getappdata() and setappdata() as shown in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
更多回答(1 个)
Amit
2014-1-16
Because UserData is not defined for other callback functions. That is why you cannot access UserData with other pushbuttons. You can define it global and that will allow this being accessed by other callbacks.
另请参阅
类别
在 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!