How can I increase the number of decimal places displayed on app designer UITable?

21 ビュー (過去 30 日間)
Jack Lebar
Jack Lebar 2024 年 8 月 15 日
コメント済み: Voss 2024 年 8 月 16 日
I am working on an app that ultimately produces 4 separate tables, each containing 4 columns of data. For simplicity, I am only including a single example, as I would think the process should be identical for all 4 tables, aside from the name of each table. All of the tables currently only show 4 decimal places. I would like to show more than this. I tried putting the following code in my startup function:
function startupFcn(app)
clc
close all
app.UITable.ColumnFormat = {'long','long','long','long'}; %4x 'long' - 1 for each column?
This does not seem to work, as all of the tables still only display 4 decimal places. Any help would much appreciated. Thank you.

採用された回答

Voss
Voss 2024 年 8 月 15 日
編集済み: Voss 2024 年 8 月 15 日
Maybe some code is modifying the uitable after the startupFcn executes, because the code you've shown should work.
Here it is working with uitables in figures (since uifigures can't be created in the forum environment):
data = rand(3,4);
n_col = size(data,2);
f_args = {'Position',[10 10 840 100]};
t_args = {'Units','normalized','Position',[0 0 1 1], ...
'ColumnWidth',repmat({200},1,n_col),'Data',data};
% a table with default ColumnFormat
f = figure(f_args{:});
t = uitable(f,t_args{:});
% another table, identical to the first, except with ColumnFormat 'long'
f = figure(f_args{:});
t = uitable(f,t_args{:});
t.ColumnFormat = repmat({'long'},1,n_col);
I have also confirmed that it works with uifigures in R2022a.
  4 件のコメント
Jack Lebar
Jack Lebar 2024 年 8 月 16 日
Perfect, that worked! Thank you. I am pretty new to App Designer so I didn't know you could write the matrix directly to the table like that. I thought because it was a table you had to feed it a "table" format. And yes sorry about the 4 columns. My table will eventually be 4 columns but I haven't yet figured out how to correctly calculate the values for the 4th column haha, so just 3 for now, with one placeholder. Thanks again for your help!
Voss
Voss 2024 年 8 月 16 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by