uitable create modify and save

4 vues (au cours des 30 derniers jours)
Pierre-François Bourdelle
Hello,
I have a 2D table and I would like to display this table and select some of lines of this table. I think the best is to create another column in my table set at 0 and when I want to select some line, I modify 0 to 1. After, I want to close the window (with a button) and retrieve the table (modified) in my Matlab workspace.
For that I choose to create an uitable. But I did not find how to :
  • Create another column to select the lines I want.
  • Create a uitable I can close with a button
  • Retrieve the table with the last column.
Thanks,
Pierre
  1 commentaire
Mohammad Sami
Mohammad Sami le 21 Jan 2020
Just add an extra column to your data, then set as the Data property of the uitable.
After you are done with the updates, retreive the Data property to see what was selected.
% change yourdata to your variable name . type is table
yourdata.lastcol = false(height(yourdata),1);
f = uifigure('CloseRequestFcn',@(varargin)uiresume(gcbf));
editcols = false(1,width(yourdata));
editcols(end) = true;
t = uitable(f,'Data',yourdata,'ColumnEditable',editcols);
uiwait(f); % this will block until the figure is closed.
updatedata = t.Data;
close(f);
delete(f);

Connectez-vous pour commenter.

Réponses (1)

Payas Bahade
Payas Bahade le 24 Jan 2020
Hi Pierre-François,
I have created a demo App in App Designer which can be used to retrieve selected lines from given table. Refer to the .mlapp file in attachment.
Instead of making use of ‘0’ or ‘1’, I have used a separate checkbox column to select the rows whose data needs to be retrieved in a variable ‘newTable’ in MATALB workspace.
Hope this helps!
  1 commentaire
Pierre-François Bourdelle
Hello Payas,
Thanks for you code, it's really helpful.
Apparently you created a class with App Designer...
Now, after some calculations, I have the table I want to show. But how to integrate your class in my existing code?
Thanks
Pierre-François

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by