When using interp3, do the input grids need to have evenly spaced values?
5 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
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.
More Answers (0)
See Also
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!