I am writing Matlab code for a project and a portion of my code is a bit of a bottleneck. I suspect it can be improved and I was hoping to get some help on that.
I have a function of 3 variables: v(x,y,z). In the attached main.m file I construct the grids for the variables x, y, z and I define the function v(x,y,z). The construction of the grid requires an external routine, gridmake.m, which I also attached.
Going forward, I want to interpolate the function v at values of x that are not necessarily on the grid. Very importantly, the values of y and z are always going to be on the grid.
Currently, I use griddedInterpolant for a 3-D interpolation, but I suspect the way I do it is too time consuming, because it does not exploit the fact that y and z are always going to be on the grid, and it is just x that will not. I will want to do this interpolation many times, so it is important that it is done most efficiently.
The attached main.m file is a short code that illustrates the problem I have. The blocks of the code have comments, describing the content, but I am happy to answer any questions you may have.
Thanks and I look forward to working with you!