I am a beginner in Matlab and I have to understand a code.
I don't understand this part where they want to do a quadratic interpolation of unevenly spaced points into a grid
for i = 1:X
for j = 1:Y
closest_pts = [x,y,z, zeros(length(x),1)];
closest_pts(:,4)= sqrt((closest_pts(:,1)-pos(1)).^2 + (closest_pts(:,2)-pos(2)).^2);
Xf = closest_pts(1:num,1); Yf = closest_pts(1:num,2); Uf = closest_pts(1:num,3);
P = zeros(num,6);
P(:,1) = 1;
P(:,2) = Xf;
P(:,3) = Yf;
P(:,4) = Xf.^2;
P(:,5) = Yf.^2;
P(:,6) = Xf.*Yf;
a = pinv(P'*P)*P'*Uf;
interp = a(1) + a(2)*pos(1) + a(3)*pos(2) + a(4)*(pos(1)^2)+...
a(5)*(pos(2)^2) + a(6)*pos(1)*pos(2);
I do understand that interp has the form ax^2+bxy+cy^2+dx+ey+f=z because it is a quadratic interpolation, and I think it is thanks to Vandermonde matrix due to the construction of P...
but I don't understand : a = pinv(P'*P)*P'*Uf;
Maybe it is just gaps in my knowledge of mathematics...
Thank you for your help!!