Interpolation of a non monotonic function

8 views (last 30 days)
Francesco Tatulli
Francesco Tatulli on 8 Dec 2016
Edited: Adam on 8 Dec 2016
Hi everyone, i hope you can help me, i know there are other topics like this but i couldn't find a solution that was fitting my problem.
This is the curve i'm working on, i need to enter with a vector on the x axis to obtain the relative y values. Honestly i don't have any idea how to solve this problem cause to be honest in theese words this wouldn't even be a function...
The only thing came up to my mind is a while cycle within a for cycle in which i enter with a random value of y using interp1 (it should work on the other side, right?) to obtain a x value and make it converge to the true one, the problem is i don't know how to make it work because i don't have a numerical relation between x and y, so i don't know how to update y when i obtain the "wrong" x... i'm sorry if i messed up with the explanation but the topic is not very easy to make it clear since i'm not english, if needed i'll try to explain again!

Answers (1)

Adam
Adam on 8 Dec 2016
Edited: Adam on 8 Dec 2016
You should just be able to loop around all your (x,y) points in pairs and interpolate between them to whatever degree of enhancement you want if linear interpolation is acceptable. Any single segment defined by two consecutive points will be monotonic by definition.
It won't necessarily be fast, but it should work at least.

Categories

Find more on Interpolation 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!