common part of two vectors

2 Ansichten (letzte 30 Tage)
Darek Myszk
Darek Myszk am 7 Nov. 2018
Kommentiert: Star Strider am 7 Nov. 2018
Hi. I Have a problem. I must to compare two vector: i.e A = [0 1 1 1 1] and B = [0 1 0 0 1]
to find two ones, in the same places in both vectors ->
I wrote something like this: [ii,jj]=find(A==B); but this also counts zero.
Thanks for help.

Akzeptierte Antwort

Star Strider
Star Strider am 7 Nov. 2018
Try this:
A = [0 1 1 1 1];
B = [0 1 0 0 1];
Result = A & B
Result =
1×5 logical array
0 1 0 0 1
  2 Kommentare
Darek Myszk
Darek Myszk am 7 Nov. 2018
Great :). My mistake, I tried to use "&&" and it didn't work. Habits from other codes. Thanks
Star Strider
Star Strider am 7 Nov. 2018
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Operators and Elementary Operations 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