Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
Pedro Guevara
Pedro Guevara 2019년 6월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
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
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.
Pedro Guevara
Pedro Guevara 2019년 6월 10일
Is there no way? through another property or anything else?

답변 (1개)

dpb
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
Pedro Guevara
Pedro Guevara 2019년 6월 11일
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 2019년 6월 11일
"I can not find a correct identifier for what I want to do."
I have no idea what that means???

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by