how to covert char array to num array?
15 ビュー (過去 30 日間)
古いコメントを表示
Mithushan Kanthasamy
2021 年 2 月 22 日
コメント済み: Walter Roberson
2021 年 2 月 23 日
how do i convert char array to num array?
arr = ['some'; 'thee'; 'time'; 'hour']
I need a way to convert into the ascii values of these char.
2 件のコメント
Walter Roberson
2021 年 2 月 23 日
The original version had 'the' instead of 'thee' so it could not be represented as a character array... which is why David answered with {}
採用された回答
David Hill
2021 年 2 月 22 日
arr={'some'; 'the'; 'time'; 'hour'};%must be cell array since lengths are not the same
for k=1:length(arr)
arr{k}=double(arr{k});%simple for-loop converts
end
2 件のコメント
Walter Roberson
2021 年 2 月 22 日
No. The best you can do is hide the loop
output = cellfun(@double, arr, 'uniform', 0)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!