Monday, 15 September 2014

MATLAB: How to concatenate two numeric matrices such that the corresponding numbers in each matrix are now concatenated -



MATLAB: How to concatenate two numeric matrices such that the corresponding numbers in each matrix are now concatenated -

for illustration lets take matrices:

a= 1 0 0 0 1 0 1 1 0 b= 1 1 0 0 0 1 1 0 0

the required result is

ab=11 01 00 00 10 01 11 10 00

try this:

reshape(mat2cell(dec2bin(a+b), ones(numel(a),1)), size(a))

or more compact suggestion rody:

reshape(num2cell(dec2bin(a+b), 2), size(a))

matlab matrix concatenation

No comments:

Post a Comment