Info
此问题已关闭。 请重新打开它进行编辑或回答。
How can I send data, or extract data, from a range of cells in a Uitable?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2019-6-10
编辑:dpb
2019-6-10
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.
回答(1 个)
dpb
2019-6-10
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 个评论
dpb
2019-6-11
"I can not find a correct identifier for what I want to do."
I have no idea what that means???
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!