Convert string array to numerical vector

조회 수: 164 (최근 30일)
John Taylor
John Taylor 2021년 3월 3일
답변: Cris LaPierre 2021년 3월 3일
I have numbers as string array A that I'd like to convert to numerical vector B:
A = ["01";"04";"12"];
B = [1; 4; 12];
I've tried with str2num but it seems to proceed only with string scalars rather than vectors.
Any tips without loop?

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 3월 3일
A = ["01";"04";"12"];
B = str2double(A)
B = 3×1
1 4 12

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by