Convert string array to numerical vector

170 Ansichten (letzte 30 Tage)
John Taylor
John Taylor am 3 Mär. 2021
Beantwortet: Cris LaPierre am 3 Mär. 2021
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?

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 3 Mär. 2021
A = ["01";"04";"12"];
B = str2double(A)
B = 3×1
1 4 12

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by