Choose numerical type for table2array output

Is there any one-command way to convert a table that holds different numeric types variables and decide the precision of the final array?
In this small example, with one double and one uint8 variable, the final array is uint8, and I want it to be double (so I do not lose information in the variable with 1000s)
T=table;
T.var1=ones(10,1,'uint8');
T.var2=1000*ones(10,1,'double');
array=table2array(T)

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 28 日

0 投票

Seomthing like this
T=table;
T.var1=ones(10,1,'uint8');
T.var2=1000*ones(10,1,'double');
array = structfun(@double, table2struct(T, 'ToScalar', true), 'uni', 0);
array = struct2array(array);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

製品

リリース

R2020a

質問済み:

2020 年 5 月 28 日

回答済み:

2020 年 5 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by