MATLAB Answers

0

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

Pedro Guevara さんによって質問されました 2019 年 6 月 9 日
最新アクティビティ dpb
さんによって コメントされました 2019 年 6 月 11 日
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 日
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 2019 年 6 月 10 日
Is there no way? through another property or anything else?

サインイン to comment.

製品


リリース

R2017b

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 件のコメント

dpb
2019 年 6 月 10 日
Well, those comments are all still true...use debugger to see where something goes awry in the callback function if it does. The above illustrates you can address given elements of the uitable so the problem has to be somewhere else in your logic or you haven't got the handles to the object correct or somesuch issue...
Not much more can do remotely, since can't reproduce your enivronment/gui locally.
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
2019 年 6 月 11 日
"I can not find a correct identifier for what I want to do."
I have no idea what that means???

サインイン to comment.



Translated by