MATLAB Answers

Converting character matrix to number

조회 수: 32(최근 30일)
John Taylor
John Taylor 3 Mar 2021
댓글: John Taylor 3 Mar 2021
I have a character matrix A that I want to convert to numbers B, but it doesn't work with str2num. Any tips? I tried B = str2num(A) but gives B = [].
A = ['02';'06';'07'];
B = [2;6;7];
  댓글 수: 2
John Taylor
John Taylor 3 Mar 2021
Ok, thanks. Character matrix then.

댓글을 달려면 로그인하십시오.

답변(1개)

Walter Roberson
Walter Roberson 3 Mar 2021
str2double(cellstr(A))
or
double(string(A))

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by