필터 지우기
필터 지우기

Using logical operator and maintaining array size

조회 수: 1 (최근 30일)
SJ Won
SJ Won 2019년 7월 4일
댓글: SJ Won 2019년 7월 4일
Say I have x = [ 0 0 1 1 1] and y = [ 4 3 6 6 8]
How do I use logical operator so that I maintain the array size? I want the result to say [ 0 0 6 6 8] - so if it's false then make them zero but keep the rest. I'm trying to avoid if or for loops if possible.

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 4일
편집: KALYAN ACHARJYA 2019년 7월 4일
Why logical? its simple multiplication.
>> x.*y
ans =
0 0 6 6 8

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by