Azzera filtri
Azzera filtri

how to change the columns of matrix using row index

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 27 Lug 2015
a(:,[s1 s2])

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by