How can I retrieve data from an editable uitable ?
조회 수: 6 (최근 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
댓글 수: 0
채택된 답변
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
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 Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!