common part of two vectors

2 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2018-11-7
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 个评论
Darek Myszk
Darek Myszk 2018-11-7
Great :). My mistake, I tried to use "&&" and it didn't work. Habits from other codes. Thanks
Star Strider
Star Strider 2018-11-7
As always, my pleasure!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by