필터 지우기
필터 지우기

Comparing 2 arrays and selecting some out of them

조회 수: 1 (최근 30일)
Ilker Enes Çirkin
Ilker Enes Çirkin 2020년 8월 28일
댓글: Ilker Enes Çirkin 2020년 8월 28일
Hi, i want to compare the elements of 2 arrays and choose the tequested values and use them in multiplication. Lets say i have 2 arrays p=[7 3 -1 2 20] and q=[1 5 -4 9 20]
and i want to find out the values of , r1 = p*(p<q). Here is what i've done so far but i seem to be stuck here because i don't know any other function to use.
p=[7 3 -1 2 20];
q=[1 5 -4 9 20];
r1 == p*[p<q];
r1

채택된 답변

madhan ravi
madhan ravi 2020년 8월 28일
  댓글 수: 6
madhan ravi
madhan ravi 2020년 8월 28일
r1 = (p .* q) .* (p < q);
Ilker Enes Çirkin
Ilker Enes Çirkin 2020년 8월 28일
that makes a lot of sense man thank you very much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by