Better method to interpn when one grid is fixed?

6 visualizaciones (últimos 30 días)
Sean
Sean el 3 de Mzo. de 2017
Comentada: Sean el 7 de Mzo. de 2017
I currently have a n-D sized database, and I'm using interpn to interpolate values from it. However, I do not interpolate on the last dimension, as I'm using the database to interpolate between 1xn solutions. The database is very large, and I am interpolating on it many times, so I'm looking for a faster solution. I believe there should be a faster solution since I'm not necessarily "interpolating" between values on the last dimension. Below is an example of my current method that I am looking to improve:
Example:
database=rand([4,4,2,3,8,6,2,6,5500]);
interpGrids={[1000 2000 4000 7000],[-5 -2 2 5],[0 1],[-5 0 5],[-20 -15 -5 0 5 10 15 20],[10 20 30 40 50 60],[-5 0],[.1 .2 .3 .4 .5 1],1:5500};
ngGriddedData=cell(1,9);
[ngGriddedData{:}]=ndgrid(interpGrids{:});
tic
solution=interpn(ngGriddedData{:},database,3000,1,1,2,-17,35,-4,.35,1:5500);
toc
Many many thanks for any suggestions. I'll be sure to send some good computing karma your way.
- Sean

Respuesta aceptada

Prashant Arora
Prashant Arora el 6 de Mzo. de 2017
Hi Sean,
You can use the griddedInterpolant function, which provides performance improvements for repeated queries to the interpolant.
F = griddedInterpolant(interpGrids,database);
tic
solution2 = F({3000,1,1,2,-17,35,-4,.35,1:5500});
toc
  1 comentario
Sean
Sean el 7 de Mzo. de 2017
Oh my goodness... I completely forgot about griddedInterpolant. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by