How can I retrieve data from an editable uitable ?
6 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Joseph Cheng
on 29 Jun 2015
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 Comments
Joseph Cheng
on 29 Jun 2015
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
More Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!