Mixed data types in a Table

34 ビュー (過去 30 日間)
Pappu Murthy
Pappu Murthy 2020 年 5 月 28 日
コメント済み: Pappu Murthy 2020 年 7 月 7 日
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.

採用された回答

Bhargavi Maganuru
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,:))));
  1 件のコメント
Pappu Murthy
Pappu Murthy 2020 年 7 月 7 日
Thanks for the workaround. Pappu Murthy.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by