Azzera filtri
Azzera filtri

problem getting correct indices of a matrix

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

Risposta accettata

Andrew Reibold
Andrew Reibold il 10 Ott 2014
Modificato: Andrew Reibold il 10 Ott 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..

Più risposte (0)

Categorie

Scopri di più su Large Files and Big Data in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by