Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

how to set some column or row in matrix to another random matrix?

1 visualización (últimos 30 días)
Firas Al-Kharabsheh
Firas Al-Kharabsheh el 16 de Abr. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
if i have (n,m) Binary matrix A like this
A = [ 0 0 0 0 1
1 0 1 1 1
0 0 0 0 0
0 0 0 0 1 ]
and i want to generate a binary random matrix and make a a rows and columns that have ones in A
to be in the same position in the random matrix like that
before the function S_rand = [ 1 0 1 0 0
1 1 0 1 0
0 1 0 1 1
0 0 1 0 1 ]
after the function S = [ 1 0 1 0 1
1 0 1 1 1
0 1 0 1 0
0 0 1 0 1 ]
where in S the second row and last column is the same in A

Respuestas (1)

Kuifeng
Kuifeng el 16 de Abr. de 2016
S_rand(selected_row, :) = A(selected_row, :);
S_rand(:, selected_col) = A(:, selected_col);

Community Treasure Hunt

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

Start Hunting!

Translated by