uitable create modify and save

조회 수: 9 (최근 30일)
Pierre-François Bourdelle
Pierre-François Bourdelle 2020년 1월 17일
댓글: Pierre-François Bourdelle 2020년 1월 24일
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
Mohammad Sami
Mohammad Sami 2020년 1월 21일
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);

댓글을 달려면 로그인하십시오.

답변 (1개)

Payas Bahade
Payas Bahade 2020년 1월 24일
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
Pierre-François Bourdelle
Pierre-François Bourdelle 2020년 1월 24일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by