## Looking for a function f(x,y,z) based on 3 points to calculate interpolat​ed/extrapo​lated values with a linear relation

### Appli Kation (view profile)

on 13 Jun 2019
Latest activity Commented on by Appli Kation

on 16 Jun 2019

### David Goodmanson (view profile)

Hello together, I am new to this forum and just starting using Matlab. Hope you could help me with my problem.
I have a "scattered" set of points with coordinates (x,y,z) that lie all in a plane.
For 3 points I have a certain measurement value. There is a linear relation between the measurement values.
Now I want to calculate the values for the remaining points. I tried 'scatteredInterpolant', 'interpn' and 'griddatan' without any success.
Do you have any suggestions for the solution?
Thank you and regards
Eugen

### David Goodmanson (view profile)

on 15 Jun 2019
Edited by David Goodmanson

### David Goodmanson (view profile)

on 15 Jun 2019

HI Appli,
This is something Matlab does really well. I assume by 'linear relation' you mean that each point has a value
c = a1*x + a2*y + a3*z with the a's to be determined. Denoting the coordinates of the three known points by p,q,r rather than x,y,z, you have the three equations
a1*p1 + a2*q1 + a3*r1 = c1
a1*p2 + a2*q2 + a3*r2 = c2
a1*p3 + a2*q3 + a3*r3 = c3
i.e. the matrix eqn. P*A = C where
P = [p1 q1 r1;
p2 q2 r2;
p3 q3 r3]
A = [a1; a2; a3] % column vector
C = [c1; c2; c3] % column vector
After constructing P and C with known values, this is solved in one line as
A = P\C
and once A is known, the rest of the C values (n of them, say) are determined by setting up the nx3 matrix
X = [x1 y1 z1;
. ..
xn yn zn]
Then
C = X*A
provides the n the values of c.

Appli Kation

### Appli Kation (view profile)

on 16 Jun 2019
Hello David,
This is exactly what I was looking for.
Thank you very much for your support!