Suppose I have 2 matrices of different dimensions. Say
A=[2 3 5 7; 1 4 8 9; 3 4 9 7]
and
B=[2; 8; 11]
then I want each element from each row of B compared with corresponding row of A and then get an output as follows:
C=[3; 9; 0]
i.e take 2 from B and look for the first element in first row of A which is greater than it. then take 8 from B and look for first element in second row of A which is greater than it. In third row since there was no element in A greater than 11, it should return zero. Is there a way I can do this without using loop? I would like to get this done through vectorization. Many thanks!
Best Answer