Adding a push button to a figure without using GUIDE

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');

 採用された回答

Adam
Adam 2014 年 12 月 5 日
編集済み: Adam 2014 年 12 月 5 日

1 投票

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');

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 12 月 5 日

0 投票

If you really want to take on the burdensome task of building a complete GUI from scratch using bunches of uicontrol() calls, see Matt Fig's File Exchange http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples

3 件のコメント

Jason
Jason 2014 年 12 月 5 日
Its only a figure that i have already plotted using subplots that I want a single button to view the ascii data!
Image Analyst
Image Analyst 2014 年 12 月 5 日
Nonetheless, there's some good stuff there. It's still worth taking a look at, at least I think so.
Jason
Jason 2014 年 12 月 5 日
Yes of course, thanks for passing the link.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

質問済み:

2014 年 12 月 5 日

コメント済み:

2014 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by