Mixed data types in a Table
조회 수: 13 (최근 30일)
이전 댓글 표시
I have an app developed using app Designer.
I have a table with 5 rows and 3 columns. These are usually double type and my numbers show up with 4 digits after the decimal point.
However, on the 5th row all 3 columns I like to be treated as integers. for e.g. Insted of [5.0000 25.0000 100.0000] I would like to display them as just [5 25 100].
my code for this part is like app.UITable.Data(5,:) = FD; where FD is a row vector with values 2 25 100 all integer*8 type.
Thanks in advance for any help.
댓글 수: 0
채택된 답변
Bhargavi Maganuru
2020년 7월 7일
If you are entering values into table using array, you cannot change the values of the last row from double to int as data type of the elements should be same in the arrays.
As a workaround, you can use cell array to store data into table and then change the datatype of the rows as shown in the following code snippet.
app.UITable.Data = {23.34,1.343,343.2;5.0000, 25.0000, 100.0000};
app.UITable.Data(2,:)=num2cell(int8(cell2mat(app.UITable.Data(2,:))));
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!