How to store data values from uitable

How would I go about storing data values typed into a uitable as globals or otherwise?

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 8 月 16 日

0 投票

DataCell = get(UitableHandle, 'Data');
global_variable_1 = DataCell{5,7}; %for example

8 件のコメント

James Hendren
James Hendren 2013 年 8 月 16 日
how do I check to make sure it is properly stored?
Walter Roberson
Walter Roberson 2013 年 8 月 16 日
You display the content of the variable.
James Hendren
James Hendren 2013 年 8 月 16 日
dat = {true, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ;...
true, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ;...
true, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' ;};
columnname = {'Fit', 'Omega', 'Lower Limit','Upper Limit', 'Gamma','Lower Limit','Upper Limit','Se','Lower Limit','Upper Limit','Sm','Lower Limit','Upper Limit','Sal','Lower Limit','Upper Limit','Sks','Lower Limit','Upper Limit'};
columnformat = {'logical', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric'};
columneditable = [true true true true true true true true true true true true true true true true true true true];
set(handles.uitable10,'Data',dat,...
'ColumnName', columnname,...
'ColumnFormat', columnformat,...
'ColumnEditable', columneditable,...
'RowName',[]);
DataCell = get(handles.uitable10, 'Data'); %stores data in globals
omega = DataCell{1,2}
the global omega returns ''
James Hendren
James Hendren 2013 年 8 月 16 日
i need it to return a value i've typed in
James Hendren
James Hendren 2013 年 8 月 16 日
do you have suggestions?
Walter Roberson
Walter Roberson 2013 年 8 月 16 日
You initialize cell {1,2} to '', and then a line later you fetch the value out again, without giving an opportunity to the user to edit the value.
Also be sure that you
global DataCell
in the routine before you assign to DataCell if you want the variable to be global.
James Hendren
James Hendren 2013 年 8 月 16 日
so how do I make it to where the user can edit the value?
Walter Roberson
Walter Roberson 2013 年 8 月 16 日
You should investigate the CellEditCallback property; see http://www.mathworks.com/help/matlab/ref/uitableproperties.html#brgcv4s
You would set it to the handle of a function; the function would execute when a cell is edited. In the function you would change the global variable.
You should consider alternatives.

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

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

質問済み:

2013 年 8 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by