フィルターのクリア

Unstructured grid to structured grid

10 ビュー (過去 30 日間)
Lorenzo
Lorenzo 2014 年 12 月 20 日
コメント済み: Emanuel 2019 年 7 月 31 日
Dear all, what would be the best way, in your opinion, to get a structured grid out of an unstructured grid?
What I have is something like this:
x y f
1 12 7
3 10 4
1 11 2
2.4 15 0
So basically x and y are totally random and in no specific order. What I need is to resample the values of f on a structured grid with a constant step.
I had a quick look at interp2 and it looks like it will only work if my vectors are strictly monotonic which is not the case as I have plenty of repeated values for x and y.
Thanks a lot

採用された回答

David Young
David Young 2014 年 12 月 20 日
編集済み: David Young 2014 年 12 月 20 日
scatteredInterpolant may do what you need. Like this:
x = [1 3 1 2.4].';
y = [12 10 11 15].';
f = [7 4 2 0].';
si = scatteredInterpolant(x, y, f); % using default linear interpolation
xint = (0.5:0.5:3.5).'; % regular grid
yint = (9.5:0.5:15.5).';
fint = si({xint yint})
  3 件のコメント
haibo xu
haibo xu 2018 年 8 月 20 日
編集済み: haibo xu 2018 年 8 月 20 日
Hi. It is worth noting that scatteredInterpolant only works on the case that x-y-z has unique values. Otherwise it will merge same numbers into one which could be out of your expectation.
Emanuel
Emanuel 2019 年 7 月 31 日
How does this work if you have a lookup table with x and y values only. So, transfer non-momotonic x values into a fixed (strictly momotonic) x step size with the corresponding (interpolated) y values ?

サインインしてコメントする。

その他の回答 (1 件)

Lorenzo
Lorenzo 2014 年 12 月 20 日
Things are getting even more difficult… I actually don't have a grid but a set of cylindrical coordinates in a plane, namely a set of values for a radius and a set of values for an angle…
Is there any way in matlab to perform the interpolation in cylindrical coordinates? The issue with treating them as cartesian is that I end up with errors at the boundaries, in my case I lose the continuity information of my surface at theta=0° or theta=360°
Any idea?
Thanks again!
  1 件のコメント
David Young
David Young 2014 年 12 月 21 日
I'd have to think that through - but scatteredInterpolant doesn't depend on having a grid at any stage - you can use the returned function, called si in my answer, to sample at any required points. To avoid the discontinuity in theta I would expect that converting everything to Cartesian coordinates might be the right thing to do.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by