Filter löschen
Filter löschen

finding same values in the same place in different columns

1 Ansicht (letzte 30 Tage)
Jos Huigen
Jos Huigen am 24 Jun. 2019
Beantwortet: Vismay Raj am 24 Jun. 2019
I have 2 columns, filled with scalars 0 or 1. I would like matlab to find all the 1's that are in the same place in one column as in the other, and the same thing for the 0's. How am I supposed to go about this? Any help would be greatly appreciated!

Akzeptierte Antwort

Vismay Raj
Vismay Raj am 24 Jun. 2019
Not the right way but gets the job done, assuming the vectors are A and B
ANSWER = ((A+B) == 2) + ((A+B) == 0)
the brackets are really important , now in answer the 1s are corresponding to the indices where both A and B match

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by