Interpolate data with 2 variables

20 views (last 30 days)
Ed Brown
Ed Brown on 3 May 2019
Commented: dpb on 4 May 2019
Hi,
I've been given a set of random engine speeds and a set of random torques and the corresponding fuel consumption data for that point. To simplify it I have this;
Engine Speed [256 509 789 1250 1449 1976]
Torque [ 22 31 48 78 112 140]
Fuel consumption [ 2568 459 440 400 329 298]
I have now been given a set of engine speeds and toruqes to find the fuel consumption at that point. The matrix of engine speeds and toruqes are larger than the data I have. I believe I need to interpolate it into a 3D graph to get the values for these points.
How do I go about this?
Many thanks

Accepted Answer

dpb
dpb on 3 May 2019
Your data are pretty sparse over the 2D space but you can try
F=scatteredInterpolant(S,T,F);
f=F(s,t);
where S,T,F are your data and s,t the lookup values.
  9 Comments
John D'Errico
John D'Errico on 4 May 2019
Edited: John D'Errico on 4 May 2019
The problem is, IF the space for yourr data to live in lies in such a narrow region, then you will find it very difficult to build a valid interpolant.
Such scattered interpolants tend to rely on triangulations of your data.
tri = delaunayTriangulation(EngineSpeed',Torque');
trimesh(tri.ConnectivityList,EngineSpeed,Torque)
Now, envision how the interpolant works. Given any point that you need to compute the fuel consumption for, the interpolant will decide which of those very long, very thin triangles the point lies inside. Once having done that, it uses linear interpolation inside the triangle, taking the fuel consumption at the 3 corner vertices of that triangle. This tends to be a VERY bad thing to do.
In fact, it is probably worse if you use an interpolation that tries to be smoother than a linear interpolation on a problem like this.
And, of course, if the point that you want to interpolate does not fall inside any of those triangles, then all interpolation gets more difficult yet.
Instead, what you want is a situation like this:
[x,y] = meshgrid(1:5);
tri = delaunayTriangulation(x(:),y(:));
trimesh(tri.ConnectivityList,x(:),y(:))
This is a much better scenario for interpolation. We see small LOCAL triangles in this second figure. Any point in question uses only points that are near it to predict the value.
So if you want a good result from interpolation, then you need to populate the region of interest as well as possible.

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!