finding missing value using interpolation

3 ビュー (過去 30 日間)
S.Sil
S.Sil 2015 年 11 月 11 日
編集済み: S.Sil 2016 年 12 月 5 日
Here is the data for the diameter and power of a hydraulic impulse

回答 (2 件)

Brandon
Brandon 2015 年 11 月 11 日
The interp1 function does not allow for extrapolation. 2.01 is outside your domain for 0 to 1.92

dpb
dpb 2015 年 11 月 11 日
Yeah, your second desired location is outside the range of the input and interp1 won't extrapolate unless it's ordered to--use
>> interp1(Diameter,Power,Given_Diameter,'linear','extrap')
ans =
2.0000 0.2367
>>
  2 件のコメント
dpb
dpb 2015 年 11 月 11 日
Looking at the relationship shown by plotting the above, looks like
interp1(Diameter,Power,Given_Diameter,'spline','extrap')
might be a better approximation than linear in this case as long as don't go very far outside the range ( always a risky proposition, anyway).
dpb
dpb 2015 年 11 月 11 日
>> plot(Diameter,Power,'x-') % original data showing points
>> hold on
>> pInterp1=interp1(Diameter,Power,Given_Diameter,'linear','extrap');
>> plot(Given_Diameter,pInterp1,'*') % linear interpolation
>> pSpln=interp1(Diameter,Power,[0:.1:2],'spline');
>> plot([0:.1:2],pSpln,'r-') % spline interpolation of original
>> pSplExt=interp1(Diameter,Power,Given_Diameter,'spline','extrap');
>> plot(Given_Diameter,pSplExt,'or') % and those interp/extrap values
>> [pInterp1;pSplExt] % compare the two choices...
ans =
2.0000 0.2367
2.0000 0.2465
>>
NB: the advantage of the spline over the linear is likely that it shows some effect of the curvature apparent in the data while the linear continues at the same slope as the last two points thus predicting lower value.
A quadratic looks like a reasonable try but if you fit it and add to the above you'll see it has a minimum before the last data point as it tries to minimize the whole curve equally.
Perhaps, depending on what it actually is, there may be reason to use a decaying exponential instead?

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

カテゴリ

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