Compute two matrices with different sizes and different values

1 vue (au cours des 30 derniers jours)
Hannes Rox
Hannes Rox le 15 Nov 2019
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

Réponse acceptée

Guillaume
Guillaume le 15 Nov 2019
it seems to me that the simplest and most reliable solution is to interpolate both velocity matrices to the same grid. Of course, whatever solution you use, you have to know:
  • the physical scale of each matrix (i.e. what is the spacing between each measurement point)
  • the location of the same reference point in both matrices (i.e. an origin)

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by