# Guessing the value of the temperature depending of the closest neighbours(3D)

2 views (last 30 days)
Charles Eloquin Leclerc on 15 Jan 2015
Answered: David Young on 15 Jan 2015
Sorry if my English isn't really good.
Basically, I got a bunch of temperature sensor in a 3D space (about 1000). Each of those sensor if giving me a temperature reading.
Here's an example :
Sensor #1, XYZ Position : [12,15,53], Temperature : 26
Sensor #2, XYZ Position : [32,25,23], Temperature : 22
etc.
I constructed a [1000x4] matrix in matlab of all the value. Now, I need a function to calculate the temperature of a random point in the XYZ space depending of this database. On my first try, I opted for the 'closest point analysis' approach but the result aren't good enough. I need a smart algorithm that'll give me a more precise temperature value by analyzing the closest neighbours.
CEL

David Young on 15 Jan 2015
If linear interpolation is sufficient, you can try
interpolant = scatteredInterpolant(m(:,1:3), m(:,4));
temp = interpolant(x,y,z);
This assumes that your data matrix is m and that x, y, z and temperature are the columns in that order.
You can also try natural neighbour interpolation by giving a further argument to scatteredInterpolant.