how could I use the "find" command to compare two matrices?

7 vues (au cours des 30 derniers jours)
Elsis
Elsis le 18 Déc 2012
Hello Matlabers,
I have 2 matrices (with 1 column and 2000 rows each) and I would like to compare each row from each matrix and get a 3rd logical matrix with 1's or 0's depending on the case... so far I tried to use the command:
control_matrix=find(A)<(B);
and this is supposed to generate a control matrix with 1's and 0's with the same size (1 column and 2000 rows) but when I apply the command it does not give me back the correct results...
any idea, suggestion or hint?
thanks! :)

Réponse acceptée

Laura Proctor
Laura Proctor le 18 Déc 2012
Modifié(e) : Laura Proctor le 18 Déc 2012
Comparing two matrices directly will give back a logical array:
control_matrix= A<B;
The find function will find the index values where items are nonzero.
  3 commentaires
Laura Proctor
Laura Proctor le 18 Déc 2012
Did you try this command? It doesn't use find. If A & B are both 1x2000 element arrays, then it will return a 1x2000 element logical array containing 1's and 0's. The use of find returns the index values. Try it!
Image Analyst
Image Analyst le 18 Déc 2012
Obviously Elsis, you did NOT try the code she provided. I think you just ran your original code instead.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by