Q: How to take the bigger of two corresponding elements, each from a vector In Matlab, suppose there are two vectors v1 and v2 of the same length. I wonder how to form a new vector w of the same length, with w(i)=max(v1(i), v2(i)) quickly? Thanks and regards!

A: How about doing
w = max(v1, v2)


octave:2> v1 = [1, 2, 3]
v1 =

   1   2   3

octave:3> v2 = [5, 1, 7]
v2 =

   5   1   7

octave:4> w = max(v1, v2)
w =

   5   2   7


A: How about
v1 = (rand(1,5) * 100)';
v2 = (rand(1,5) * 100)';
w =  max(v1,v2);

