Interp3 Producing Unexpected Output?

2 ビュー (過去 30 日間)
John Chilleri
John Chilleri 2017 年 5 月 20 日
コメント済み: John Chilleri 2017 年 5 月 20 日
Hello,
When using the default trilinear interpolation of interp3, I'm getting an unexpected output:
>> Interpval = interp3(X,X,X,V,X(10),X(5),X(1))
Interpval =
2.373878950731685e+04
>> V(10,5,1)
ans =
2.423129551369272e+04
where X is an n x 1 vector, and V is an n x n x n matrix.
I expected the two results to match as it should notice that the interpolation point is a grid point.
Why do the results not match?
Hopefully I'm just tired and this is a trivial question.
Thanks for your time and help.

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 20 日
>> X = sort(randn(1,25));
>> V = rand(25,25,25);
>> Interpval = interp3(X,X,X,V,X(10),X(5),X(1))
Interpval =
0.505428142457703
>> V(10,5,1)
ans =
0.844855674576263
>> V(5,10,1)
ans =
0.505428142457703
In other words, confusion over the fact that interp3's first coordinate is X, second coordinate is Y, whereas indexing in MATLAB has first coordinate corresponding to Y and second coordinate corresponding to X.
  1 件のコメント
John Chilleri
John Chilleri 2017 年 5 月 20 日
This was the case - I wasn't thinking about grids, I was thinking about 3D space. Row and column formatting switch the X and Y...
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolating Gridded Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by