interp1 fails to interpolate correctly

조회 수: 11 (최근 30일)
Nate
Nate 2019년 11월 17일
댓글: Vladimir Sovkov 2019년 11월 19일
I have a set of input data which the function interp1 is incorrectly interpolating.
For a statement Vq = interp1(X,V,Xq), I have
X =
-0.0124393747904463
0.0134396235257952
0.0344412390769423
0.0850313641677704
0.0850004675375172
0.126329531171773
V =
-4
-2
0
2
4
6
Clq =
0.0772456107479591
The result interp1 gives me is Vq = 3.3864734865877. This is clearly wrong, but may be related to the face that between V = 4 and V =6, X is not monotonically increasing/decreasing. Can someone help me understand why this is failing?

채택된 답변

Matt J
Matt J 2019년 11월 17일
편집: Matt J 2019년 11월 17일
X needs to be montonically increasing (or interp1 will pre-sort the data so that it is).

추가 답변 (1개)

Vladimir Sovkov
Vladimir Sovkov 2019년 11월 18일
Why do you consider it is wrong? In the plot (see the attachment) this result looks quite reasonable.
  댓글 수: 5
Walter Roberson
Walter Roberson 2019년 11월 19일
polynomial fits cannot solve double-valued functions.
Sometimes you should use a function of two variables instead.
Sometimes you can rewrite as a parameteric function.
Sometimes you just need to segment to decide which function is in control. For example hysterisis has to be handled as a pair of functions, not by trying to fit one single function.
Vladimir Sovkov
Vladimir Sovkov 2019년 11월 19일
Maybe, switching roles of X and V can help, e.g.:
VV=fzero(@(z)(interp1(V,X,z)-Clq),1)
VV=1.69220264208349

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by