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

조회 수: 1 (최근 30일)
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');

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by