MATLAB Answers

Jim
0

comparing vectors for max and min

Asked by Jim
on 29 Sep 2014
Latest activity Commented on by Jim
on 29 Sep 2014
I am comparing two numerical vectors a and b. I want to create two new vectors-one is the element by element minimum of a(i) and b(i). The other has the maximums. are there functions that do this? The vectors are the same length.

  1 Comment

Did you try the documentation for min and max ?

Sign in to comment.

1 Answer

Answer by Alberto
on 29 Sep 2014
 Accepted Answer

Functions max and min do the trick:
a=randi(9,1,10)
b=randi(9,1,10)
vect_max = max(a,b)
vect_min = min(a,b)

  1 Comment

Thanks. I did not read far enough into the min and max documentation.

Sign in to comment.