Convert some columns in 'double array' to single digit, rest as bank and then put in UITable

2 ビュー (過去 30 日間)
Jason
Jason 2021 年 1 月 21 日
回答済み: Jason 2021 年 1 月 25 日
Hello, I have an array (class='double)
T =
1.0000 1.0000 1.0000 1.3521 0.1780 0 1.3966 10.0000
2.0000 1.0000 2.0000 0.9910 0.1720 0 1.4454 10.0000
3.0000 1.0000 3.0000 1.1243 0.1800 0 1.4053 10.0000
4.0000 1.0000 4.0000 1.0776 0.1750 0 1.3999 10.0000
5.0000 1.0000 5.0000 1.0350 0.1770 0 1.3809 10.0000
6.0000 1.0000 6.0000 0.9700 0.1750 0 1.4079 10.0000
7.0000 1.0000 7.0000 0.9111 0.1730 0 1.4379 10.0000
8.0000 1.0000 8.0000 1.1395 0.5280 0 1.4052 10.0000
9.0000 1.0000 9.0000 1.0037 0.1750 0 1.3662 10.0000
I want to insert this into a UITable but have column 1,2 & 3 with no decimals.
So I have tred this
T=app.Timings % My data
class(T) % 'double'
C1=num2str(T(:,1),'%.0f');
C2=num2str(T(:,2),'%.0f');
T(:,1)=C1(:,1)
T(:,2)=C2(:,1)
app.UITable2.Data=T;
T2=app.UITable2;
T2.ColumnFormat = {'char' 'char' 'char' 'bank' 'bank' 'bank' 'bank' 'bank'};
%app.UITable2.DisplayData
But Im getting weird results

採用された回答

Jason
Jason 2021 年 1 月 25 日
I found this works:
C = num2cell(T)
app.UITable2.Data=C;
app.UITable2.ColumnFormat={'char','char','char','bank','bank','bank','bank','bank'};

その他の回答 (1 件)

Mario Malic
Mario Malic 2021 年 1 月 21 日
Hello,
Issue in your code is on this line. You asked for the number with 0 decimals, replace 0 with how many decimals you want there to be and it should be working.
C1=num2str(T(:,1),'%.0f');
  2 件のコメント
Jason
Jason 2021 年 1 月 21 日
Hi, I want zero decimals i.e. integer only
Mario Malic
Mario Malic 2021 年 1 月 21 日
C1=num2str(T(:,1),'%d');

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

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by