How can I interpolate/ curve-fit 1D scattered data?
Show older comments

Hi all,
I am trying to interpolate between these points, ideally I'd like to have a smooth"ish" curve passing through the points. I'm not sure how to proceed.
I have tried to convert the data to polar coordinates and use interp1:
[thi,ki]=cart2pol(xi,yi);
dth=0.01
th_int=-pi:dth:p
ki_int= interp1(thi,ki ,th_int,'pchip','extrap');
But I've been getting the "The grid vectors must contain unique points." error. I then tried a different approach by fitting a smoothing spline to the polar data.
cfit=fit(thi',ki','smoothingspline')
ki_int = feval(cfit,th_int)';
It seems to work pretty well, but if I transform it back to Cartesian coordinates
[xint,yint]=pol2cart(th_int,ki_int);
I get the following figure: the fit is good except in that one region.

Any help would be greatly appreciated, it seems like it should be a fairly easy problem to solve but I can't figure it out.
Thanks,
Clemence
Ps: I'm using the R2016a academic version and I have the curve-fitting toolbox.
Accepted Answer
More Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!