How to do this copying from matrix to random matrix ?
2 views (last 30 days)
Show older comments
if i Generate a binary random (n,m) matrix and after some steps i found A_matrix like this
A_matrix = [ 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 1 0 0
1 1 1 1 1 1 1 0 1 1
0 0 0 0 0 0 0 1 0 0
1 0 0 0 0 0 0 1 0 0
1 0 0 0 0 0 0 1 0 0 ]
i want to generate another randomly matrix but i want
- the row that have more than the half of ones compered by m (number of ones > m/2) copy as it is in the new matrix
- the column that have more than the half of ones comperd by n (number of ones > n/2) copy as it is in the new matrix
X_before = [ 1 0 0 1 0 0 1 0 1 0
1 0 1 0 0 0 1 0 1 0
0 1 0 1 0 1 0 0 0 0
0 0 1 0 1 0 0 1 0 1
0 1 0 1 0 1 0 0 1 1
0 0 1 0 1 1 1 0 0 0 ]
X_after = [ 1 1 1 1 1 1 1 1 1 1
0 0 1 0 0 0 1 1 0 0
1 1 1 1 1 1 1 0 1 1
0 1 0 1 0 1 0 1 0 0
1 0 1 0 1 0 0 1 0 1
1 1 0 1 0 1 0 1 1 1 ]
where A_matrix (1,:) and (3,:) and (:,8) are equal to X_after (1,:) and (3,:) and (:,8)
- note i do not need to use this way A_natrix(1,:) = X_after(1,:) because its can be change if the A_matrix changed
0 Comments
Answers (0)
See Also
Categories
Find more on Particle & Nuclear Physics 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!