Effacer les filtres
Effacer les filtres

How to do this copying from matrix to random matrix ?

1 vue (au cours des 30 derniers jours)
Firas Al-Kharabsheh
Firas Al-Kharabsheh le 2 Mai 2016
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

Réponses (0)

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by