MATLAB: How to count in arrays

arrayscounting

Let's say I have two arrays
apple = [1 2 3 4 5 6 7 8];
pear = [2 3 1 2 7 6 1 8];
I want to compare these arrays and count how many items in pear are bigger than the item at the same place in apple. How would I do this?

Best Answer

x=sum(pear>apple);
Related Question