Column Format in UI Table

조회 수: 140 (최근 30일)
Klemen Peter Kosovinc
Klemen Peter Kosovinc 2019년 8월 29일
댓글: Walter Roberson 2022년 1월 11일
I have table array in data of UI table.
There are a few columns in my table:
Num1 Num2 Text
5.2345 4.2345 JN
-> I would like to have only two decimals in the first two columns. What is the best way to pull this of? I would like that data in the UI table remains table array.

채택된 답변

Ankit
Ankit 2019년 9월 30일
편집: Ankit 2019년 9월 30일
hey,
you can set the format of your table as follows using 'ColumnFormat' property. Are you looking for something like this?
Case: Programatically creating GUI
f = figure('Position', [100 100 752 250]);
t = uitable('Parent', f, 'Position', [25 50 700 200]);
t.ColumnName = {'Num1','Num2','Text'};
t.Data = {5.2345, 4.2345,'JN'};
t.ColumnFormat = {'bank' 'bank' []};
Case: StartupFcn as follows (App Designer)
function StartUpFunction(app)
app.UITable.Data = {5.2345, 4.2345,'JN'};
app.UITable.ColumnFormat = {'bank' 'bank' []};
end
regards
Ankit

추가 답변 (2개)

Navya Seelam
Navya Seelam 2019년 9월 27일
Hi,
You can use format as shown below.
format bank
table.Data=table.Data % to update the table data to current format
  댓글 수: 6
Klemen Peter Kosovinc
Klemen Peter Kosovinc 2019년 10월 1일
I have app, which I made in appdesigner. I added table object.
-> In the code I fill the UI table with data.
exampleTable = table();
exampleTable.num1 = 5.2345;
exampleTable.num2 = 4.2345;
exampleTable.Text = {'JN'};
app.UItable.data = exampleTable;
---- added lines -----
format bank
app.UItable.data = app.UItable.data;
Walter Roberson
Walter Roberson 2019년 10월 3일
The format command has no effect on graphics. You should follow Ankit's solution

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


Navya Seelam
Navya Seelam 2019년 10월 3일
Hi,
The issue can be resolved by passing the data to uitable from cell array rather than table.
  댓글 수: 3
jesus pacheco
jesus pacheco 2022년 1월 11일
@Klemen Peter Kosovinc Hi Bro, I have the same Problem. could you solve it?

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

카테고리

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