Borrar filtros
Borrar filtros

Comparing two vectors with different dimensions

8 visualizaciones (últimos 30 días)
osminbas
osminbas el 14 de Jun. de 2012
Hello,
How can you compare two vectors with different number of elements? I am just trying to find the equal elements. Thanks!

Respuesta aceptada

the cyclist
the cyclist el 14 de Jun. de 2012
Your question is fairly vague, but I have a feeling that either the ismember() command or the intersect() command will help you do what you want.
  1 comentario
osminbas
osminbas el 14 de Jun. de 2012
Sorry I wasn't clearer. And yes, intersect was what I was looking for. Thank you!

Iniciar sesión para comentar.

Más respuestas (1)

Rohan Kale
Rohan Kale el 19 de Jun. de 2012
Let a and b be two arrays(or vectors). L=length(a), M=length(b).Suppose L>M, pad_zero=L-M; now b=[b zeros(1,pad_zero)]; c=a-b; now you can find the indices of the zero elements excluding the last pad_zero elements. These are your desired indices. Hope it helps.
  2 comentarios
the cyclist
the cyclist el 19 de Jun. de 2012
Uh ... isn't it a lot easier to just use [c ia ib] = intersect(a,b)?
Rohan Kale
Rohan Kale el 19 de Jun. de 2012
yes it is indeed, I was just trying out an alternative....

Iniciar sesión para comentar.

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