extract logical locations that match array

조회 수: 1 (최근 30일)
ALDO
ALDO 2019년 10월 9일
댓글: ALDO 2019년 10월 9일
Hi I know this might be simple but i have a logical array and another double arry with the same length. I want to extract the value of the locations in array two that correspond to to 1 in the logical array.
A=1 0 1 1 0
B= 77 5 2 8 9
I did the following
C=and(A,B)
D=B(C)
but it only gives me D= 77 2 8. I want the result to include zero for the locations that dont match. so ans would be D= 77 0 2 8 0
I would appriciate any help on this! Thanks in advance!

채택된 답변

Adam
Adam 2019년 10월 9일
B .* A
would seem to give what you want
  댓글 수: 1
ALDO
ALDO 2019년 10월 9일
Thank you so much. worked perfectly!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by