Representing a number as a matrix
显示 更早的评论
Hi, I'm looking for how i would be able to seperate a number's digits and to then have these stored as a matrix. So for example if the number was 146, this would then be split such that matrix X = [1,4,6] Any help would be greatly appreciated. Thanks
采纳的回答
更多回答(1 个)
Matt Fig
2011-2-26
One approach:
N = arrayfun(@str2num,sprintf('%i',146))
or (along the lines of James' answer)
N = sprintf('%i',146)-'0'
类别
在 帮助中心 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!