interp1 returns finite value when input is NaN

Dear sirs,
Consider the following two examples:
>> interp1([1 2 3 4 5], [48 47 1 1 1], NaN)
ans =
NaN
>> interp1([1 2 3 4 5], [48 48 1 1 1], NaN)
ans =
48
In the first case, it behaves as I would expect, i.e. an undefined input gives an undefined output. However in the second, the output is suddenly finite.
When trying different combinations. it seems:
If the two first "y" samples in the x/y data to interpolate are equal, then this is given as the answer as output for NaN as input. Which to me makes completely no sense at all.

3 件のコメント

Jan
Jan 2016 年 11 月 15 日
編集済み: Jan 2016 年 11 月 15 日
"Dear sirs and ladies" would sound more polite.
Please specify your Matlab version. R2009a replies NaN in both cases.
Opening interp1.m in the editor and stepping through it line by line by the debugger should reveal the cause of this strange behavior.
dpb
dpb 2016 年 11 月 15 日
>> interp1([1 2 3 4 5], [48 48 1 1 1], NaN)
ans =
NaN
>> interp1([1 2 3 4 5], [48 47 1 1 1], NaN)
ans =
NaN
>>
Which release?
>> version
ans =
8.0.0.783 (R2012b)
>>
Looks like a bug to me...but check release notes to see if there is some documented change (altho I'd certainly not expect this one to be intended, there have been some revisions to interp1)
KSSV
KSSV 2016 年 11 月 16 日
It returns NaN in both of the cases. My version 2015a.

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

回答 (1 件)

Cosmin Ionita
Cosmin Ionita 2018 年 2 月 1 日
編集済み: Cosmin Ionita 2018 年 2 月 1 日

0 投票

This issue has been fixed in MATLAB R2017a:

カテゴリ

ヘルプ センター および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

製品

質問済み:

2016 年 11 月 15 日

編集済み:

2018 年 2 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by