I've just noticed that actually using the interpolant to find my wind speed, air tempearture etc. at the desired location is also taking up a lot of time (60% of my overall run time) whilst the scattered interpolation takes up around 35% of my overall run time.
Speeding up interpolation with scattered interpolation
52 次查看(过去 30 天)
显示 更早的评论
Hi,
I've been working on speeding up my code for a project and I've identified that I'm spending a lot of time interpolating my data. I have data for wind speeds, air temperature, pressure and a few other things that depend on position in the X,Y and Z directions. I've been using ScatteredInterpolation to interpolate across 1425 data points and then using the interpolant find the wind speeds, air temperature, pressure etc. at a specific position. I was wondering if there was a faster way to do this, either speeding up scatteredinterpolation or a different interpolating method. Am fairly new to MATLAB so help appreciated.
Thanks.
4 个评论
Torsten
2023-12-10
The points are spaced every 0.25 lat and long and there is data for 57 different altitudes.
If this is the case, why don't you use GriddedInterpolant instead of ScatteredInterpolant ? The interpolation afterwards will be much faster.
采纳的回答
Matt J
2023-12-10
编辑:Matt J
2023-12-10
Your data is gridded, so you should be using griddedInterpolant, as opposed to scatteredInterpolant. Gridded interpolation is much faster than scattered interpolation.
TemperaturePrevious0 = griddedInterpolant( {LatData0,LonData0,AltitudeData0}, TemperatureArrayPrevious)
Also...
Once I've interpolated im using the interpolant to find the atmospheric properties at a given point.
...you should not interpolate one point at a time. You should supply a vector of query points and interpolate them in a single call.
4 个评论
Matt J
2023-12-10
I've tried the above code but i keep getting the following error:
It means one of the coordinates you are interpolating (Lat, Lon, Altitude) has less than two sample points.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!