Turning a char element in a double array

1 Ansicht (letzte 30 Tage)
Teoman Selcuk
Teoman Selcuk am 18 Okt. 2021
Beantwortet: the cyclist am 18 Okt. 2021
How can I turn a char element into an array of double values. I am trying to get the Expected Output below but array_convert does not work. How would I be able to get the Expected Output below?
Code:
a = char('[21,12,43,1]')
array_convert= str2double(a)
Expected Output:
[21 12 43 1]

Antworten (1)

the cyclist
the cyclist am 18 Okt. 2021
a = char('[21,12,43,1]');
array_convert = str2num(a)
array_convert = 1×4
21 12 43 1

Kategorien

Mehr zu Data Type Conversion 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