pchip extrapolation?

조회 수: 16 (최근 30일)
Tim
Tim 2011년 12월 19일
Hi All Trying to use pchip to process sensor data from raw digital values. Seems to work fine when the raw values are within the range of calibration values used us inputs to pchip. However, when raw values are smaller than those values used to calibrate the sensor the output is unexpected. Using the example for pchip from Mlab help:
x = -3:3; y = [-1 -1 -1 0 1 1 1]; t = -3:.01:3; p = pchip(x,y,t);
pchip (x,y,-4); ans = -1 (as expected)
However, if change y to:
y = [-1 -0.98 -0.94 0 0.94 0.98 1];
pchip (x,y,-4); ans = -0.9933
Why do answers for x values <-3 increase? I would expect them to linearly decrease i.e. pchip (x,y,-4); ans = -1.02
Thanks in advance

채택된 답변

Robert Cumming
Robert Cumming 2011년 12월 19일
your extrapolating quite far (compared to the source data), plot the data and you will see why the numbers are not what "you expect" - extrapolation must always be treated with care.
x = -3:3;
y = [-1 -1 -1 0 1 1 1];
t = -3:.01:3;
plot ( [-5:0.01:5], pchip(x,y,[-5:0.01:5]), 'r' );
hold on;
y = [-1 -0.98 -0.94 0 0.94 0.98 1];
plot ( [-5:0.01:5], pchip(x,y,[-5:0.01:5]), 'k' );
grid on
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 12월 19일
"Prediction is very difficult, especially if it's about the future."
(Nils Bohr)
Robert Cumming
Robert Cumming 2011년 12월 19일
Indeed...
maybe I should have put "extreme" care...

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

추가 답변 (1개)

Andrew Newell
Andrew Newell 2011년 12월 19일
Why would you expect the output to be linear when the input isn't? Look at the end points:
y = [-1 -0.98 -0.94 0 0.94 0.98 1];
diff(y)
ans =
0.0200 0.0400 0.9400 0.9400 0.0400 0.0200
If you change y to
y = [-1.02 -0.98 -0.94 0 0.94 0.98 1.02];
then you do get linear extrapolation: pchip(x,y,-4) is equal to -1.06.
EDIT: moreover, the extrapolation remains linear for larger absolute values.

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by