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

조회 수: 6 (최근 30일)
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.

채택된 답변

John D'Errico
John D'Errico 2020년 1월 7일
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
Blenndrman
Blenndrman 2020년 1월 7일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by