Clear Filters
Clear Filters

Comparing 2 arrays and selecting some out of them

1 view (last 30 days)
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

Accepted Answer

madhan ravi
madhan ravi on 28 Aug 2020
r1 = p(p<q);
  6 Comments
Ilker Enes Çirkin
Ilker Enes Çirkin on 28 Aug 2020
that makes a lot of sense man thank you very much.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!