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

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 commentaires

dpb
dpb le 10 Juin 2019
Modifié(e) : dpb le 10 Juin 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.
Is there no way? through another property or anything else?

Réponses (1)

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 commentaires

First of all, thank you very much for your help. Look, what I really want to do had already posted it some time but nobody knew how to answer me. I leave the link to POST for you to tell me if it can be done and how I could do it. I appreciate your help and I hope you can give me a hand.
Until now I notice that the only person who had told me in that POST was you. :(
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.
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.
"I can not find a correct identifier for what I want to do."
I have no idea what that means???

Cette question est clôturée.

Produits

Version

R2017b

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by