How to separate a matrix randomly
Show older comments
Hello everyone, I want to ask how to separate a matrix randomly. For example, I have a matrix
A = [...
0 0 0 0
0 0 0 0
1 1 1 1
1 1 1 1]
and I need a C1 and C2 matrix:
C1 =
0 0 0 0
0 0 0 0
1 0 0 1
0 1 1 0
C2 =
0 0 0 0
0 0 0 0
0 1 1 0
1 0 0 1
Is it possible we can generate them by separating the 1 digit randomly?
Thanks before :)
Accepted Answer
More Answers (1)
Andrei Bobrov
on 1 Dec 2014
C1 = randi([0 1],size(A)).*A;
C2 = A - C1;
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!