Overlap of 2 logicals

조회 수: 14 (최근 30일)
Cside
Cside 2020년 2월 24일
댓글: Star Strider 2020년 2월 24일
I have 2 logicals, B and B2 of the same size (120x9), and would like to find the number of overlaps of 1s(true) in B and B2 of the same row and column. Was wondering if there is any function to code for this. I have attached B and B2 for easy access.
Thank you :)

채택된 답변

Star Strider
Star Strider 2020년 2월 24일
Since ‘B’ and ‘B2’ have not yeat appeared, try this with synthetic versions of them:
B = randi([0 1], 5, 6) > 0
B2 = randi([0 1], 5, 6) > 0
C = B & B2
NumberOfOverlaps = nnz(C)
You can shorten the code to:
NumberOfOverlaps = nnz(B & B2)
I kept them separate to demonstrate how the code works.
  댓글 수: 2
Cside
Cside 2020년 2월 24일
thank you star strider, totally overlooked & :)
Star Strider
Star Strider 2020년 2월 24일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 JSON Format에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by