Finding 4 closest points

8 ビュー (過去 30 日間)
Sanskar Patel
Sanskar Patel 2021 年 4 月 23 日
回答済み: Rik 2021 年 4 月 23 日
Hi,
So I am trying to use bilinear interpolation to extrapolate data for certain values of a 3-dimensional array. But, the issue is that the bilinear interpolation requires an input of the 4 closest numbers by distance in order for the equations to be solved. Does anyone have an idea of how I can obtain these 4 values. I am going to put some context below for better understanding.
62 0 63 0
0 0 0 0
63 0 61 0
0 0 0 0
I am going to refer to the coortinates of the elements in the form of (row,column).
So for example, consider this array above. For context, I need a way to find the 4 closest non-zero points to (1,2). If I solved this manually, the points would be (1,1),(1,3),(3,1),(3,3).
This is only a small part of a very large array that I have given for context. If anyone can help me with the coding, it would be appreciated.
  1 件のコメント
Jonas
Jonas 2021 年 4 月 23 日
編集済み: Jonas 2021 年 4 月 23 日
what aboit using find() with two output arguments which gives you the x and y index of the nonzero elements. after then you can calculate on the base of this indices the distance to the locations you are interested in.

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

回答 (1 件)

Rik
Rik 2021 年 4 月 23 日
You can design something yourself, but you could also see if fillmissing solves your problem. The documentation suggests it should work for 3D arrays as well.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by