MATLAB: Adding a push button to a figure without using GUIDE

figurepushbutton

Is there a reason why I'm not seeing the pushbutton on the figure? Thanks Jason
hFig=figure('Position',[200 200 1600 600]);
movegui(hFig,'center')
%Add pushbutton to view data
ButtonH=uicontrol('Parent',hFig,'Style','pushbutton','String','View Data','Position',[0.0 0.5 0.4 0.2],'Units','normalized','Visible','on');

Best Answer

You have to specify the Units before the Position else default units of characters are used, meaning your push button will be minuscule with your current code. Use this instead:
ButtonH=uicontrol('Parent',hFig,'Style','pushbutton','String','View Data','Units','normalized','Position',[0.0 0.5 0.4 0.2],,'Visible','on');
Related Question