Borrar filtros
Borrar filtros

how to copy rows and columns in a random matrix ?

1 visualización (últimos 30 días)
Firas Al-Kharabsheh
Firas Al-Kharabsheh el 18 de Abr. de 2016
Respondida: Azzi Abdelmalek el 18 de Abr. de 2016
if i have matrix A
A = [ 1 0 1 1
0 0 1 0
0 1 0 1
1 1 0 1 ] ;
THEN i want to generate a random binary matrix S which the first and last row IN A appear in S matrix
AND the last column In A appear in S matrix ?
S = [ 1 0 1 1
0 1 0 0
1 0 1 1
1 1 0 1 ]

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Abr. de 2016
S=randi([0 1],size(A))
S([1 end],:)=A([1 end],:)
S(:,end)=A(:,end)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by