## Compute two matrices with different sizes and different values

### Hannes Rox (view profile)

on 15 Nov 2019 at 11:33

### Guillaume (view profile)

on 15 Nov 2019 at 12:32

### Guillaume (view profile)

Hello,
I'm investigating the flow field in a stirred tank and made pictures with two cameras, which were taking pictures from various angles of view. The computed values of the velocity vectors are stored in different sized matrices (e.g.: size of 1st matrix v = [161 94]; size of 2nd matrix vPart = [164 100]). The rows represent the height of the tank and the columns the width. My problem is, that I have to calculate the difference between the two velocities. First of all, I can't just substract the matrices due to the different sizes and secondly, I have to subtract the appropriate values ​​from each other. Means, I have to check if the coordinates of the two different velocities fit together, so that I can make sure, I'm computing the same position in the tank even though the cameras have different perspective. Therefore I'm comparing the different coordinate-vectors and find the nearest cells. If the distance between the coordinates is too big, I set the variable set to zero, because it's not guaranteed anymore that I'm comparing the same position in the tank. So far, that's my idea, but it didn't work out. That's why I wanted to ask if someone knows another solution or if you find a relevant error in the following code.
vslip = zeros(length(yPart),length(xPart));
for j = 1:length(yPart)
diffy = abs(yPart(j)-y);
rowy = min(diffy);
[rowy,~] = find(diffy==rowy);
if yPart(j)-y(rowy) < 0.1
for l = 1:length(xmean)
diffx = abs(xmean(l)-x);
rowx = min(diffx);
[rowx,~] = find(diffx==rowx);
if xmean(l)-x(rowx) < 0.1
vslip(j,l) = vPart(j,l) - v(rowy,rowx);
else
vslip(j,l) = 0;
end
end
end
end