Info

This question is closed. Reopen it to edit or answer.

How can I send data, or extract data, from a range of cells in a Uitable?

1 view (last 30 days)
Good night all. My problem is the following. I have a uitable of "n" number of rows and 9 columns. I want to send information that I have in a variable, to the first 5 columns and the "n" rows of my uitable. I'm testing with the command:
data ( V_org ( Pos_igual1x (j,1) ) , 6 ) = datos ( V_org (Pos_igual1x (j,1) , 1 ) , 6) ;
data ( V_org ( Pos_igual1x (j,1) ) , 7 ) = datos ( V_org (Pos_igual1x (j,1) , 1 ) , 7) ;
set(handles.TablaDatosElementos,'Data', data) ;
But this code does not allow me to give the range of cells I need. Could someone help me please? Thank you very much in advance.
  2 Comments
dpb
dpb on 10 Jun 2019
Edited: dpb on 10 Jun 2019
The "Data" property is all the data in the uitable; there is no facility to subscript and assign subsets---you can read the present content; modify sections of that content in memory and then store the modified array, but that's the bestest can do as far as I can tell...there's no indication of any addressing facility in the documentation.

Answers (1)

dpb
dpb on 10 Jun 2019
Well, experimenting shows you can address subarrays...one of the examples given modified slightly--
hF=figure; % create new figure
data=randi(100,10,3); % some data that stays fixed so can compare
hUIt=uitable(hF,'Data',data,'Position',[20 20 262 204]); % put into the table
>> hUIt.Data % observe what we did...returns all data
ans =
45 50 35
95 7 81
58 53 58
79 32 82
72 86 9
15 1 20
70 21 63
40 89 7
13 22 75
65 32 61
>> hUIt.Data(3,3) % access a given element
ans =
58
>> hUIt.Data(3,3)=75; % set to a new value -- works
>> hUIt.Data(:,3)=575; % a full column addressing also works as expected
So, one of those cases where even though the doc doesn't say so and there are no examples that illustrate the syntax, it does work after all so my previous comment was in error.
Now, I can't decipher what it is you're trying to do in the original question, but if you address the data stored in the table 'Data' property correctly, you should be able to update any specific cell or group of cells desired. The limitations will be on what the content of the cell is--numeric or cellstr or what--your addressing mode and syntax will have to be consistent and you can't mix different types into one addressing expression.
  5 Comments
Pedro Guevara
Pedro Guevara on 11 Jun 2019
I do not think there are any problems with the logic of the program. The only thing that happens is that I can not find a correct identifier for what I want to do. I have not tried your previous solution yet, because right now I am involved in the project. As soon as I try it, I'll tell you how it went. Thanks for your help.
dpb
dpb on 11 Jun 2019
"I can not find a correct identifier for what I want to do."
I have no idea what that means???

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!