Hello, I have two matrices A and B of dimensions m-by-3 and n-by-3 respectively where n < m (they are basically RGB values of an image). For sake of simplicity assume m = 8 and n = 4. For each row in m, I need to calculate the the norm of the difference of that row with the each row of n. The way I am doing it now is using a nested for loop, but my m and n are way higher. So this is taking forever to run. I was wondering if there is any other efficient way to do it.
Just for the sake of completion here is my code for performing this operation:
for i = 1:size(m, 1) for j = 1:size(n, 1) d(j, 1) = norm(m(i, 1) - n(j, 1)) end % I do some stuff with d here, but its not important to the
question.end
Thanks.
Best Answer