Representing a number as a matrix
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Matt Fig
el 26 de Feb. de 2011
One approach:
N = arrayfun(@str2num,sprintf('%i',146))
or (along the lines of James' answer)
N = sprintf('%i',146)-'0'
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!