How do I vectorize each digit of an integer and store it as an array?
조회 수: 30(최근 30일)
표시 이전 댓글
I have to convert an integer into a vector of all its digits. Example: 100---> [1 0 0]
function ans = int2vec(x)
Though this worked for me, is there a better solution.
Stephen23 2018년 5월 8일
편집: Stephen23 2018년 5월 8일
1 0 0
If you want all digits, regardless of position and role (e.g. exponent):
>> s = num2str(100);
1 0 0
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!