extract Vector's index from Matrix

2 visualizaciones (últimos 30 días)
Fatma Gargouri
Fatma Gargouri el 14 de Nov. de 2011
Hello,
I have a matrix M size(M)=n*2
and a Vector V size(V)=n*1
in the fist colomn of M we find some indexes of V I want to extract the indexes of V which are not used in M.
is that possible?
thank you

Respuesta aceptada

Grzegorz Knor
Grzegorz Knor el 14 de Nov. de 2011
ismember function might be helpful.

Más respuestas (2)

Walter Roberson
Walter Roberson el 14 de Nov. de 2011
Much more directly:
setdiff(V, M(:,1))

Fatma Gargouri
Fatma Gargouri el 14 de Nov. de 2011
thank you Grzegorz Knor
K=M(:,1);
p=1;
for i=1:size(V,1)
ind=ismember(i,K);
if ind==0
R(p)=i;
p=p+1;
end
end

Categorías

Más información sobre Resizing and Reshaping Matrices 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