Filter löschen
Filter löschen

Reading multiple values from an n*1 cell array.

1 Ansicht (letzte 30 Tage)
Hayden Garmon
Hayden Garmon am 23 Jun. 2020
Kommentiert: Hayden Garmon am 23 Jun. 2020
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?

Akzeptierte Antwort

Stephen23
Stephen23 am 23 Jun. 2020
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

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by