problem getting correct indices of a matrix

3 visualizaciones (últimos 30 días)
Christopher
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!

Respuesta aceptada

Andrew Reibold
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..

Más respuestas (0)

Categorías

Más información sobre Large Files and Big Data en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by