how to add one space to a matrix ?
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (2)
s = dec2bin(rand(50,1)*2^32);
t = repmat(' ', size(s, 1), size(s, 2) * 2 - 1);
t(:, 1:2:end) = s;
2 Kommentare
I don't know what CA rule 150 is so why don't you explain it.
It is now clear however, that your original question is a case of xy problem. Looking at your attempted code, you don't need to insert spaces and actually want to operate on numbers rather than strings.
xor certainly does not work with strings.
See comment on my own answer for a possible solution.
yonatan gerufi
am 9 Nov. 2014
0 Stimmen
see in the "file exchange" :
3 Kommentare
janny
am 9 Nov. 2014
yonatan gerufi
am 9 Nov. 2014
perhaps i misunderstood you.
the code : dec2bin(rand(50,1)*2^32)
gives you string of ones & zeros. you can pad it with ' ' (space), and then you will have space between the elements.
Image Analyst
am 9 Nov. 2014
It gives a 2D character array, not a simple string. I think maybe he wants all those rows concatenated together with a space in between them.
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!