Reading multiple values from an n*1 cell array.

1 次查看(过去 30 天)
I am trying to convert an n*1 cell array into an n*5 matrix of doubles
{'3.748 2.858136 21.447754 13.853117 -9.113155'}
{'3.749 2.869758 21.443939 13.816126 -9.117885'}
Does anyone know how to do this?

采纳的回答

Stephen23
Stephen23 2020-6-23
The most efficient way:
>> C = {'3.7482.85813621.44775413.853117-9.113155'; '3.7492.86975821.44393913.816126-9.117885'};
>> M = sscanf(sprintf(' %s',C{:}),'%f',[5,Inf]).'
M =
3.74820 0.85814 0.44775 0.85312 -9.11316
3.74920 0.86976 0.44394 0.81613 -9.11788

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by