MATLAB Answers

Column Format in UI Table

154 views (last 30 days)
Klemen Peter Kosovinc
Klemen Peter Kosovinc on 29 Aug 2019
Commented: Walter Roberson on 3 Oct 2019
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.

Answers (3)

Ankit
Ankit on 30 Sep 2019
Edited: Ankit on 30 Sep 2019
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

Navya Seelam
Navya Seelam on 27 Sep 2019
Hi,
You can use format as shown below.
format bank
table.Data=table.Data % to update the table data to current format
  6 Comments
Walter Roberson
Walter Roberson on 3 Oct 2019
The format command has no effect on graphics. You should follow Ankit's solution

Sign in to comment.


Navya Seelam
Navya Seelam on 3 Oct 2019
Hi,
The issue can be resolved by passing the data to uitable from cell array rather than table.
  1 Comment
Klemen Peter Kosovinc
Klemen Peter Kosovinc on 3 Oct 2019
Yes, I know that. But I do not want to use cell array rather than table. I want to use table, because I can then index the columns with the column names.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!