How do I get information about selected column in UItable?
42 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
First of all,
I would like to make matlab app as below in appdesigner
- Make table from data
- Select column from table I want to see
- Plot data which selected column from table.
So I tried to get event.Indices, but actually I don't know how to do that
Some colleagues replied that just use below kind of function, but matlab says no field named Indices like below fig.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/999300/image.png)
Actually, I just would like to see how event.Indices are structed so that I use the structure to handle data.
Could you please help me out?
Thanks
1 comentario
Geoff Hayes
el 16 de Mayo de 2022
@병주 김 - I think the problem is that you are trying to get the Indices from the event object of the push button callback and not the UITable cell selection callback. I think that you want to do something similar to https://www.mathworks.com/matlabcentral/answers/364338-how-to-get-indices-of-selected-uitable-cell-outside-cellselection-callback (which I see you have commented on) so that the cell selection callback does the following
% (Add selectedCell property to store indices)
% Cell selection callback: UITable
function UITableCellSelection(app, event)
app.selectedCell = event.Indices;
end
and that your push button callback would then get that data and use it to plot
function CallbackButtonPushed(app, event)
% get the data from the table using app.selectedCell
% plot the data
end
So you still need two callbacks - one to save the selected columns, and one to plot the data.
Respuestas (1)
Kanishk
el 20 de En. de 2025 a las 12:00
Geoff has captured the callback function on the "UITable" to get the selected cells. Following this way, you have to store the details to be accessed later in the button pushed callback function.
You can also access the indices of selected cells directly in any callback function using the “DisplaySelection” Property of “UITable”.
function ButtonPushed(app, event)
app.UITable.DisplaySelection
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1823711/image.png)
1 2
2 2
3 2
4 2
5 2
6 2
7 2
8 2
To learn more about "DisplaySelection" Property, please use this link to access the official MATLAB documentation.
- https://www.mathworks.com/help/releases/R2024b/matlab/ref/matlab.ui.control.table.html
- https://www.mathworks.com/help/releases/R2022a/matlab/ref/matlab.ui.control.table-properties.html (For older MATLAB version)
Thanks!
0 comentarios
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!