Turning a char element in a double array

조회 수: 1 (최근 30일)
Teoman Selcuk
Teoman Selcuk 2021년 10월 18일
답변: the cyclist 2021년 10월 18일
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]

답변 (1개)

the cyclist
the cyclist 2021년 10월 18일
a = char('[21,12,43,1]');
array_convert = str2num(a)
array_convert = 1×4
21 12 43 1

카테고리

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