Getting error while using interpolation function

2 ビュー (過去 30 日間)
R7 DR
R7 DR 2015 年 2 月 18 日
編集済み: John D'Errico 2015 年 2 月 20 日
While using interpoltaion function I am getting the follwing error.
*Undefined function 'interpl' for input arguments of type 'double'.
Error in interpolation (line 16) G=interpl(a,d,x); *
I wrote the code like this
t=[1:10]
a=[0.1:0.1:1]
d=[20:30]
x=0.45
Y=interp1(a,t,x);
G=interpl(a,d,x);
The code is working for 'Y', but if I added 'G' it is showing error.
What is wrong with my code?
Thanks

採用された回答

John D'Errico
John D'Errico 2015 年 2 月 18 日
編集済み: John D'Errico 2015 年 2 月 18 日
Whats wrong? That you can't type? :)
I copied a piece of the error message that you got.
c = 'interpl'
c =
interpl
upper(c)
ans =
INTERPL
See that in the second call, you typed interpl, although you meant interp1. In fact, as soon as I saw the error, I knew this is what you had done. This is one of those mistakes you make once, then immediately know what to look for in the future, but it is difficult to debug.
  4 件のコメント
R7 DR
R7 DR 2015 年 2 月 18 日
Now the error message is like this
Error using griddedInterpolant The grid vectors do not define a grid of points that match the given values.
Error in interp1 (line 183)
F = griddedInterpolant(X,V,method);
Error in interpolation (line 16)
G=interp1(a,d,x);
John D'Errico
John D'Errico 2015 年 2 月 20 日
編集済み: John D'Errico 2015 年 2 月 20 日
The original error you got was ABSOLUTELY due to exactly what I said it was.
While you think you typed it properly, you did not. The error message that MATLAB gave repeated the name of the function you used.
"*Undefined function 'interpl' for input arguments of type 'double'."
What looks like a 1 in the function name is indeed a lower case L. MATLAB cannot lie.
Once you typed it properly, then a second error happens. The second error happens because a and t have 10 elements, so the first call works. But then the vector d has 11 elements.
You cannot form an interpolation mapping between the vectors a and d when a and d have a different number of elements. That would make no sense, so interp1 generates the error.
Had you used
d = 21:30;
the second call to interp1 (if spelled properly) would work with no problem.

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

その他の回答 (0 件)

カテゴリ

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