MATLAB: How to fit a curve where it turns back

boomerang curvecurve fitting

Hi, i would like to fit a curve with:
x=[0 0.8 1.4 1.2 1]
y=[0.4 0.8 1.4 0.8 0.4]
However, when I try it with curve fitting app, it always ignore the sequence of x, turn out to be:
but I need it to be like this:
How to make it to follow the sequence given in x? Thank you

Best Answer

You can use tools like cscvn.
Or you can use my interparc tool, found on the file exchange, which has several alternative methods available.
And of course, you can write code to do the work yourself. The first two options are better choices though. Always look for high quality code that does what you need before writing it yourself.
Related Question