Faster interpolation than interp2 ?
39 views (last 30 days)
Hey guys, I have a question. I am currently using interp2 for interpolation of single points on a grid. In my case it is
So lat and lon are the sample grid points (this is how matlab calls it. they get created by meshgrid), u_now_flow is a flow field and b and a are vectors which look like this:
so the code is working fine, but I wanted to know if there are faster ways/functions to interpolate the points on a grid. I tried to use griddedInterpolant, but failed cause I always got NaN, but I have no idea why. I hope you can help me
Guillaume on 5 Dec 2016
griddedInterpolant may be marginally faster than interp2 since interp2 does a little bit of argument manipulation before finally using griddedInterpolant to do the heavy work. I wouldn't expect the difference to be significant enough that it'd matter.
There are no other interpolating methods in matlab that are faster.
Using griddedInterpolant, your code should be:
ginterp = griddedInterpolant(lat, lon, u_now);
k1u = ginterp(a, b); %assuming a and b are vectors of the same length and shape.