I have a column vector (5000×1) and a matrix (5×3). I want to find the maximum index (ii = 1,2,3) for each element of the vector against each row of the matrix where the vector element is less than or equal to the indexed element. I will end up with a matrix of size (5000×5). If the vector element is greater than all elements in a row, return 3 as the index.
Example with a (6×1) vector and (5×3) matrix:
v = [1 1 2 1 2 3]'; A = [0 1 2 1 2 3 0 0 0 1 1 2 2 3 4];Output (6x5): B = [2 1 3 1 1 2 1 3 1 1 3 2 3 3 1 2 1 3 1 1 3 2 3 3 1 3 3 3 3 2];
Best Answer