Borrar filtros
Borrar filtros

How to do this copying from matrix to random matrix ?

1 visualización (últimos 30 días)
Firas Al-Kharabsheh
Firas Al-Kharabsheh el 2 de Mayo de 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

Respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by