how can I interpolate?

hi all. I have some data and I want to interpolate z in this data. I used this code:
% year2012=xlsread('year2012');
year2012=double(year2012);
X=year2012(1:91,1);
Y=year2012(1:91,2);
Z=year2012(1:91,3);
x=year2012(1:91,4);
y=year2012(1:91,5);
z = interp2(X,Y,Z,x,y);
but I have this error :
% Error using griddedInterpolant
The coordinates of the input points must be finite values; Inf and NaN are not permitted.
Error in interp2>makegriddedinterp (line 228)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 128)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in new (line 19)
z = interp2(X,Y,Z,x,y,'nearest');code
I attached my data and I think my data is true. can you please guide me?

2 件のコメント

per isakson
per isakson 2016 年 5 月 18 日
Hint:
jack nn
jack nn 2016 年 5 月 19 日
thanks dear Isakson. I just used 1:91 in my code.

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

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2016 年 5 月 18 日

0 投票

F = scatteredInterpolant(X,Y,Z);
out = F(x,y);

6 件のコメント

jack nn
jack nn 2016 年 5 月 19 日
編集済み: jack nn 2016 年 5 月 19 日
thanks dear Andrei Bobrov. I used this and I got answer.. but Is this work like interpolation? I mean that Imagine that we have X and Y and our observation in this point IS Z and (X,Y) is nearest point to (x,y) and now we should find the observation in (x,y) point, z. Is this code can help me? this picture may help you.
thanks
Walter Roberson
Walter Roberson 2016 年 5 月 19 日
zbar = F(xbar, ybar)
jack nn
jack nn 2016 年 5 月 20 日
thanks dear Walter Roberson. what is F in this command? how can I define this function?
Walter Roberson
Walter Roberson 2016 年 5 月 20 日
Like Andrei posted, F = scatteredInterpolant(X,Y,Z);
jack nn
jack nn 2016 年 5 月 20 日
thanks, dear Walter Roberson. Can I ask an other question?
Walter Roberson
Walter Roberson 2016 年 5 月 20 日
Go ahead and create another Question.

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

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

質問済み:

2016 年 5 月 18 日

コメント済み:

2016 年 5 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by