Interp2d with NaN values (2D-Interpolation)

9 ビュー (過去 30 日間)
fjnb86
fjnb86 2012 年 8 月 15 日
I have XI and YI variables as two row vectors. The sequences contain some missing values represented by NaN.
On the other hand, I have X,Y,Z are complete matrices (any nan)
I would like to perform interp2d method:
ZI = interp2(X,Y,Z,XI,YI)
ZI must be a vector with the length of XI,YI but the algorithm is not able to calculate the interpolation when data is missing.
What I want, is to deal with those missing data, rather than to make up some fake data that could screw up my analysis.
In other words, I want to obtain a ZI with NaN values at the same position of XI and YI.
how can I can do this in MATLAB? I am also open to other suggestions on how to deal with these missing values.

採用された回答

Jan
Jan 2012 年 8 月 18 日
valid = ~isnan(XI) & ~isnan(YI);
ZI = nan(size(XI));
ZI(valid) = interp2(X, Y, Z, XI(valid), YI(valid));
  1 件のコメント
fjnb86
fjnb86 2012 年 8 月 21 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by