My goal is to find smoothing curve for the large amount of non-uniformly spaced data, such that minimal amplitude of curve is as big as possible. "csaps" function seems to be what I need, because it allows to get different degree of smoothing by varying smoothing parameter p. I was trying different kind of optimizations for this, but figured out that results are incorrect. "csaps" function produces non-smooth result for low values of p. And this is the most interesting range of smoothing parameter for me. For making minimum working example it would be necessary to attach data in *.mat file. I don't know how to do it. But, if I run the following code on my data:
plot(cv,pr,'.','DisplayName','data')
hold on
grid on
cvi=linspace(0,cv(end),10000);
p=1e-5;
pp = csaps(cv,pr,p);
plot(cvi,ppval(pp,cvi),'k-','LineWidth',2,'DisplayName',['p=',num2str(p)])
p=1e-10;
pp = csaps(cv,pr,p);
plot(cvi,ppval(pp,cvi),'r-','LineWidth',2,'DisplayName',['p=',num2str(p)])
legend('Location','best')
I get:
For p=1e-10 the smoothing curve looks non-smooth for small values of cv.
I have tried fnval instead of ppval but this makes no improvement. Does anybody know why this happens and how can I get good smoothing for large dataset?