Message Boards Message Boards

0
|
4702 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

[?] Implement a flat right interpolation?

Posted 6 years ago

Hello, Ii am using Interpolation function with my table and I would like to implement a flat right interpolation; looking at the InterpolationOrder->0 it seems it does a flat left interpolation. Is there any method available to perform the flat right? thank you best regards

POSTED BY: Tarpanelli Paolo
3 Replies

Thank you It works P

POSTED BY: Tarpanelli Paolo

One way is to negate your x axis, interpolate to get f[x], and then use f[-x].

Example:

valList = {{0, 1}, {1, 3}, {2, 5}, {3, 2}, {4, 0}, {5, -1}};
if = Interpolation[valList, InterpolationOrder -> 0];

Plot[if[x], {x, 0, 5}]

enter image description here

But what (I think) you want is this.

if2 = Interpolation[Map[{-1, 1}*# &, valList], 
   InterpolationOrder -> 0];

Plot[if2[-x], {x, 0, 5}]

enter image description here

POSTED BY: Daniel Lichtblau

Wouldn't that just mean moving all your y values by one to the right?

valso=Transpose[{Range[10],Sin[0.3Range[10]]}];
fi=Interpolation[valso,InterpolationOrder->0]
vals=Transpose[{Range[10],RotateRight[Sin[0.3Range[10]]]}];
fi2=Interpolation[vals,InterpolationOrder->0]
Show[{Plot[{fi[x],fi2[x]},{x,1,10}],ListPlot[valso]}]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract