how to change the columns of matrix using row index

2 visualizaciones (últimos 30 días)
nadia nadi
nadia nadi el 27 de Jul. de 2015
Comentada: nadia nadi el 13 de Sept. de 2015
dear all,
I have this matrix
a=[1 0 0 0 1 0; 0 0 1 0 0 1;1 0 1 0 0 0;0 0 1 0 0 1;1 1 0 0 0 0;1 0 0 0 0 0;0 0 0 1 0 0];
I chose first row and wrote it as [ 1 1 0 0 0] and I want to rearrange the matrix depends on I, I used the index
a=[1 0 0 0 1 0; 0 0 1 0 0 1;1 0 1 0 0 0;0 0 1 0 0 1;1 1 0 0 0 0;1 0 0 0 0 0;0 0 0 1 0 0];
row=a(1,:);
s=find(row==1);
row1=[0 0 0 1 1 0];
s1=find(row1==1)
s2=find(row1==0)
%a=a(:,row1);give error
to here I don't now how to use the index of row1 to change a, can anyone help me please.
regards

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Jul. de 2015
a(:,[s1 s2])
  1 comentario
nadia nadi
nadia nadi el 13 de Sept. de 2015
Dear Walter,
sorry for late to accept your answer. Thanks.
Nadia

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing 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