MATLAB: How to add one space to a matrix

binary operationsstring manipulation

am using this code to generate binary matrix dec2bin(rand(50,1)*2^32) but i need to add one space between the matrix element so i can use it for other commands. the output matrix needs space to be useful for other calculation. how to do this?

Best Answer

The following would work:
m = dec2bin(rand(50,1)*2^32)
mwithspaces = cell2mat(regexprep(num2cell(m, 2),'\d(?=\d)', '$0 '));
I have to ask though, why do you want to do that? It seems like an unnecessary step. I would think that any algorithm that follows is probably going to remove these spaces one way or another.
edit: was missing a bracket