How to use interp1 with data neither in increasing order nor decreasing order.

8 views (last 30 days)
I have two data sets. One is in increasing order while its corresponding value is in random order (neither increasing nor decreasing only). I know interp1 can be used only for increasing data sets. Let me know how can i use it for this particular case.
Please reply at the earliest. Thanks!

Answers (2)

Star Strider
Star Strider on 4 Jun 2016
The interpolation functions such as interp1 require only that the independent variable be monotonically non-decreasing. The dependent variable can do anything it wants to.

Azzi Abdelmalek
Azzi Abdelmalek on 4 Jun 2016
Edited: Azzi Abdelmalek on 4 Jun 2016
x=0:2:10 % is sorted
y=rand(size(x)) % y is not sorted
xi=[1 3 5]
yi=interp1(x,y,xi)
If this is what you've asked, this example shows it works

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!