Converting character matrix to number
古いコメントを表示
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 件のコメント
Your example shows a character matrix, not a "vertical string vector" nor a "character vector".
This is a vertical string vector:
S = ["02";"006";"4"]
This is a character vector:
V = '0001'
whos
John Taylor
2021 年 3 月 3 日
回答 (1 件)
Walter Roberson
2021 年 3 月 3 日
str2double(cellstr(A))
or
double(string(A))
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!