how to covert char array to num array?
11 次查看(过去 30 天)
显示 更早的评论
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!