How to do this copying from matrix to random matrix ?

1 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by