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.

 Respuesta aceptada

Ankit
Ankit el 30 de Sept. de 2019
Editada: Ankit el 30 de Sept. de 2019

2 votos

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

Más respuestas (2)

Navya Seelam
Navya Seelam el 27 de Sept. de 2019

0 votos

Hi,
You can use format as shown below.
format bank
table.Data=table.Data % to update the table data to current format

6 comentarios

Klemen Peter Kosovinc
Klemen Peter Kosovinc el 30 de Sept. de 2019
Hi,
thank you for your answer. I tried changing the format as you suggested.
It is true - when I open the variable from workspace, there are only 2 decimals.
But, the table in the app remains the same (I still have 4 decimals). And I want to change the number of decimals in the app.
Navya Seelam
Navya Seelam el 30 de Sept. de 2019
Hi,
You can try changing the format in the function where you update the table contents.
Klemen Peter Kosovinc
Klemen Peter Kosovinc el 30 de Sept. de 2019
I did actually. No success. :(
Navya Seelam
Navya Seelam el 30 de Sept. de 2019
Can you attach your code?
Klemen Peter Kosovinc
Klemen Peter Kosovinc el 1 de Oct. de 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 el 3 de Oct. de 2019
The format command has no effect on graphics. You should follow Ankit's solution

Iniciar sesión para comentar.

Navya Seelam
Navya Seelam el 3 de Oct. de 2019

0 votos

Hi,
The issue can be resolved by passing the data to uitable from cell array rather than table.

3 comentarios

Klemen Peter Kosovinc
Klemen Peter Kosovinc el 3 de Oct. de 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.
jesus pacheco
jesus pacheco el 11 de En. de 2022
@Klemen Peter Kosovinc Hi Bro, I have the same Problem. could you solve it?

Iniciar sesión para comentar.

Categorías

Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.

Preguntada:

el 29 de Ag. de 2019

Comentada:

el 11 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by