Column Format in UI Table

154 visualizzazioni (ultimi 30 giorni)
Klemen Peter Kosovinc
Klemen Peter Kosovinc il 29 Ago 2019
Commentato: Walter Roberson il 11 Gen 2022
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.

Risposta accettata

Ankit
Ankit il 30 Set 2019
Modificato: Ankit il 30 Set 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

Più risposte (2)

Navya Seelam
Navya Seelam il 27 Set 2019
Hi,
You can use format as shown below.
format bank
table.Data=table.Data % to update the table data to current format
  6 Commenti
Klemen Peter Kosovinc
Klemen Peter Kosovinc il 1 Ott 2019
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 il 3 Ott 2019
The format command has no effect on graphics. You should follow Ankit's solution

Accedi per commentare.


Navya Seelam
Navya Seelam il 3 Ott 2019
Hi,
The issue can be resolved by passing the data to uitable from cell array rather than table.
  3 Commenti
jesus pacheco
jesus pacheco il 11 Gen 2022
@Klemen Peter Kosovinc Hi Bro, I have the same Problem. could you solve it?

Accedi per commentare.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by