How can I retrieve data from an editable uitable ?

11 次查看(过去 30 天)
Hello!
I created the following editable uitable in a new figure:
dataInput = cell(3,8);
global tableInput
%Input table's creation
rnamesInput = {'A','B','C'};
tableInput = uitable('ColumnWidth',{70},...
'parent', tab1, ...
'Position',[30 20 480 93], ...
'data',dataInput, ...
'ColumnEditable',true(1,8), ...
'RowName',rnamesInput);
I am now trying to retrieve data into variables. For example, if I enter values "4" at Column1-Row1, "25" at Column1-Row2 and "18" at Column1-Row3, I expect to have the variables "A = 4", "B = 25" and "C = 18". So I am now wondering how can I retrieve my data from this uitable? Do I have to create 3x8 variables in order to put each cell's value in it or can it be done "automatically" (these variables will be used in an other function)?
Thank you in advance for your help :)
Mana

采纳的回答

Joseph Cheng
Joseph Cheng 2015-6-29
you would use the get() functionality to retreive the data. And these are not "variables" as you are calling them. they are indexing locations like in excel. you can retrieve the user input values using the last line in the code there with the get() function.
dataInput = cell(3,8);
global tableInput
figure,
pos = get(gcf,'position');
set(gcf,'position',[pos(1:2) [660 120]])
%Input table's creation
rnamesInput = {'A','B','C'};
tableInput = uitable('ColumnWidth',{70},...
'Position',[30 20 600 80], ...
'data',dataInput, ...
'ColumnEditable',true(1,8), ...
'RowName',rnamesInput);
%gen data because so i do not have to enter it in manually for the
%example
dummydata = reshape(1:3*8,3,8);
set(tableInput,'data',num2cell(dummydata))
retreivedata = get(tableInput,'data')
  3 个评论
Joseph Cheng
Joseph Cheng 2015-6-29
So how would you normally extract data from a cell array for the column 1 row 2. http://www.mathworks.com/help/matlab/getting-started-with-matlab.html i point you here to get the basics of matlab but you would index it like you would normally.
retreivedata(2,1) %row 2 column 1

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by