# problem getting correct indices of a matrix

1 visualización (últimos 30 días)
Christopher el 10 de Oct. de 2014
Comentada: Christopher el 10 de Oct. de 2014
I have the code:
odif = find(o~=on); % element index: combos with O==O
pdif = find(p(odif)~=pn(odif)); % element index: combos with O==O and P~=P
psam = find(p(odif)==pn(odif)); % element index: combos with O==O and P==P
where o, on, p, and pn, are equal size matrices. odif is found correctly. The code is supposed to get a vector of indices (odif) where elements in o and on are different. So far, so good.
Then, AMONG those elements o(odif), find the elements for which p and pn are different (pdif) or equal (esam). The problem is that pdif and psam return the indices for the vector odif, and NOT the indices for the the matrices o1/o1n/p1/p1n. How do I change this, so that I get the indices for the matrices and not the vector odif? Thank you!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Andrew Reibold el 10 de Oct. de 2014
Editada: Andrew Reibold el 10 de Oct. de 2014
Try this maybe?
odif = find(o~=on); % element index: combos with O==O
pdif = odif(find(p(odif)~=pn(odif))); % element index: combos with O==O and P~=P
psam = odif(find(p(odif)==pn(odif))); % element index: combos with O==O and P==P
No time to test..
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Christopher el 10 de Oct. de 2014
looks like that works, thanks!

Iniciar sesión para comentar.

### Categorías

Más información sobre Large Files and Big Data 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