When using interp3, do the input grids need to have evenly spaced values?

5 views (last 30 days)
When using interp3, do the input grids need to have evenly spaced values? In other words, I need to know how to avoid the "Input grid is not a valid MESHGRID" error, despite the requirement that I use a specific set of input grids upon which I need to interpolate.

Accepted Answer

John D'Errico
John D'Errico on 7 Jan 2020
No. They do not need to be EVENLY spaced. So a grid spacing of [1 2 4 8 15 17 23 100] is entirely valid. Though depending on the shape of your function, it may produce good or bad interpolation results. Long stretches where the function is highly nonlinear are a problem.
You do need a grid however. Something, for example, that meshgrid would have produced. If you don't understand that, then you need to read the help for meshgrid carefully. Such a grid will be aligned with the axes of your coordinate system, though, again, they need not be purely linear and uniform along those axes.
You CANNOT have scattered data, so data where the points do not lie on a cartesian grid.
Be careful, as there is a difference between ndgrid and meshgrid. meshgrid produces the ordering you will need, and only meshgrid.
  1 Comment
Blenndrman
Blenndrman on 7 Jan 2020
Thanks, that's a clear answer, and it's appreciated. Turns out, the function we use to produce the data that forms the grid is nonmonotonic (a loose word in 3D, but that's ok), and there's no way around this. Is there a trick here? A different function other than interp3, perhaps?

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!