Building a GUI from user input

2 ビュー (過去 30 日間)
pradeep kumar
pradeep kumar 2014 年 11 月 1 日
回答済み: Image Analyst 2014 年 11 月 1 日
Hellow everyone ! I am entirely new to MATLAB . i want to build a GUI like this
Row = [text box 1]
Column = [text box 2]
[button]
When i click the button , it shall create a (Row X Column ) size table and i will be able to extract the data from the table for further processing . I have no idea on this .Please help me . Thanks

採用された回答

Zoltán Csáti
Zoltán Csáti 2014 年 11 月 1 日
function myGUI
S.f = figure;
S.row = uicontrol('Style','edit', 'Units','normalized', ...
'Position',[0.4 0.6 0.1 0.1]);
S.column = uicontrol('Style', 'edit', 'Units','normalized', ...
'Position',[0.6 0.6 0.1 0.1]);
S.btn = uicontrol('Style','push', 'String','Create table', ...
'Units','normalized', 'Position',[0.5 0.5 0.1 0.1]);
set(S.btn, 'Callback',{@createtable,S});
function createtable(varargin)
rowSize = str2num(get(S.row, 'String'));
colSize = str2num(get(S.column, 'String'));
initdata = zeros(rowSize,colSize);
S.table = uitable('Parent',S.f, 'Data', initdata, ...
'Units','normalized', 'Position',[0.4 0.2 0.4 0.2], ...
'ColumnEditable',logical(ones(1,colSize)));
end
end
  3 件のコメント
Zoltán Csáti
Zoltán Csáti 2014 年 11 月 1 日
The position of the objects can easily be modified, it is just a sketch. If you wan to export the table values after editing, you can do it by saving the data values that can be extracted from the 'Data' field of S.table.
Zoltán Csáti
Zoltán Csáti 2014 年 11 月 1 日
I learnt from the MATLAB Documentation, asked questions here and I found the following contribution very helpful: 41 Complete GUI Examples. This book is also advantageous if you want to learn GUI-making. And most importantly, practise a lot!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 11 月 1 日
For a simpler, more interactive way, use GUIDE, so you don't have to figure out dozens of input parameters for uicontrol(). See this tutorial http://blogs.mathworks.com/videos/category/gui-or-guide/

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by