フィルターのクリア

interpolate using selected values of a matrix

1 回表示 (過去 30 日間)
Muhammad Hasnat
Muhammad Hasnat 2013 年 1 月 25 日
I have 2D data X = [ 1 NaN 3 4 5 ; 6 NaN 8 9 10; 11 12 13 14 15]; I want to find the interpolated value at the location (2.5,2.5). A simple interp2 command interp2(X,2.5,2.5) will return an NaN at the location (2.5,2.5) Is there anyway I can do this interpolation, i.e ignore certain values in the matrix/data and use only selected values for interpolation ?

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 1 月 25 日
X = [1 nan 3 4 5;6 nan 8 9 10;11 12 13 14 15];
[jj,ii] = ndgrid(1:size(X,1),1:size(X,2));
t = ~isnan(X);
F = TriScatteredInterp(ii(t),jj(t),X(t));
Xnew = F(ii,jj);
% your case
X2 = F(2.5,2.5);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by