button in a figure
35 次查看(过去 30 天)
显示 更早的评论
How to add a button in a figure that changes the line style of a subplot,without using GUIDE?
1 个评论
the cyclist
2014-6-3
Maybe I misunderstand, but isn't a button that a user pushes, by definition, a graphical user interface?
回答(1 个)
David Sanchez
2014-6-5
try this:
S.f = figure; S.h=plot(rand(10,1)); % creates a figure and plot something on it
% create a pushbtton ( adapt it to your needs)
S.pb = uicontrol('style','push',...
'units','pix',...
'position',[10 10 180 40],...
'fontsize',14,...
'string','Change line',...
'callback',{@pb_call,S});
%callback function for the pushbutton (save it in its own *.m file if needed)
function pb_call(varargin)
S = varargin{3}; % Get the structure.
set(S.h,'LineStyle','+')
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!