Hello MATLABers!
I am currently updating some software and I decided to add a table. In the table, I want certain cells to grab certain data numbers. For example, my table will have two columns and 4 rows. I would like the second column and third row to output the time my function takes to run. I am familiar with the set function for normal callbacks.
For example: set(handles.textBox, 'String', message);
Is there a method similar to this with tables? Any advice is welcome :D

 Respuesta aceptada

Brendan Hamm
Brendan Hamm el 14 de Sept. de 2015
Editada: Brendan Hamm el 14 de Sept. de 2015

0 votos

A uitable is just storing the data in a Property named 'Data'. I show two examples, one for a matrix and the other a cell array, for syntax prior to and after the 2014b release.
f1 = figure;
myCellTable = uitable(f1,'Data',cell(4,2));
myCellTable.Data{3,2} = 10; % This could be a call to the toc function for time
f2 = figure;
myMatTable = uitable(f2,'Data',zeros(4,2));
myMatTable.Data{3,2} = 10;
So the basic idea is the uitable is an object and we can index it's property with dot-notation (post 2014b). Prior to 2014b we need to get, modify and set, like oyu show above.
f3 = figure;
myCellTable = uitable(f3,'Data',cell(4,2));
CellData = get(myCellTable,'Data');
CellData{3,2} = 10;
set(myCellTable,'Data',CellData);
f4 = figure;
myMatTable = uitable(f4,'Data',zeros(4,2));
MatData = get(myMatTable,'Data');
MatData(3,2) = 10;
set(myMatTable,'Data',MatData);
Edit: Note that the latter syntax still works post 2014b.

4 comentarios

Khaled Aboumerhi
Khaled Aboumerhi el 14 de Sept. de 2015
How can I do this with a table in a GUI?
Brendan Hamm
Brendan Hamm el 14 de Sept. de 2015
The exact same way, but using the handle for the table in the GUI. I'm not sure if your question is trying to ask more than this. If so, please elaborate.
Khaled Aboumerhi
Khaled Aboumerhi el 15 de Sept. de 2015
No I think I got it! Thank you, good sir!
Mohamed Abdelhameed
Mohamed Abdelhameed el 11 de Mayo de 2017
Brendan, I have a question. I am working with Artificial Neural Network. I made a table for the inputs and a table for the output. I want the network to take the first row as the input and project the output in the second table (GOR). Take a look at the picture.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.

Preguntada:

el 14 de Sept. de 2015

Comentada:

el 11 de Mayo de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by