MATLAB: A way to replace a single number array to a double array.

array

Hi, there is a simple way (like array(array(:)==1)=5), to do this:
array=
[ 1
1
0
0
1 ];
to
array=
[ 1 0
1 0
0 1
0 1
1 0 ];
Andre

Best Answer

a=[ 1
1
0
0
1 ];
out = [a, ~a]+0;