MATLAB: Combining elements in an array

concatenation

Hi, I have a logical array, A = [1 0 1]. How can I combine the elements horizontally, so that I have B = [101]? Any help would be appreciated! SS

Best Answer

To turn your logical array into a double array, any mathematical operation on it will do the conversion. Here I used ‘+’:
A = logical([1 0 1])
An = +A
whos A*
A =
1 0 1
An =
1 0 1
Name Size Bytes Class Attributes
A 1x3 3 logical
An 1x3 24 double