I want to multiply the elements of c1 (with corresponding values t1) with the matching elements of c2 (corresponding to the values of t2).
c1
t1
c2
t2
For example, for
t1 = {1, 2, 3, 4, 5, 6, 7} c1 = {12, 19, 34, 48, 35, 40, 47} t2 = {2, 4, 6} c2 = {21, 45, 17}
I want to get
{19*21,48*45,40*17}
Any idea for doing it?
Yes, that works in Ehud's example. But not if t1 is a permutation of Range@Length@c1
Range@Length@c1
t1 = {1, 5, 2, 7, 4, 3, 6}; c1 = {12, 19, 34, 48, 35, 40, 47}; t2 = {5, 7, 3}; c2 = {21, 45, 17}; Pick[c1, t1, n_ /; MemberQ[t2, n]]*c2 c1[[t2]]*c2
Another way:
c1[[t2]]*c2
One way using Pick:
Pick
t1={1,2,3,4,5,6,7}; c1={12,19,34,48,35,40,47}; t2={2,4,6}; c2={21,45,17}; Pick[c1,t1,n_/;MemberQ[t2,n]]*c2