How can I retrieve data from an editable uitable ?

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

 Accepted Answer

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

Thank you for your answer, but how will I be able to use data from the cell at Column1-Row2 (for example) into an other function? The get() function allows me to have an access to the full table's data but not to a specific one.
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
Thanks that is exactly what I was looking for!

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Asked:

on 29 Jun 2015

Commented:

on 30 Jun 2015

Community Treasure Hunt

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

Start Hunting!