Splines: How to find vector/array from smoothing line (function - csaps), or another function (still using a smoothing parameter)?

6 次查看(过去 30 天)
Question: Consider the coding:
sample = 100; % Data points
x = linspace(-5,5); % Data bounds
y= 1.6 * x.^2 +6; % Function
r = randn(10,sample); % Add noise
p = 0.1; % Specify "smoothness"
pp = csaps(x,y,p); % Specify Spline/Smoothing line
hold on
plot(x,r(1,:)+y,"b") % Blue :Plot random data
plot(x,y,"k") % Black :True "y data"
fnplt(pp,"r") % Red :Plot Spline/Smoothing line
Just like I have the precise data of vectors "y" and "r", I would like to have the corresponding data from the smoothing-line (Which is not exactly the same as vectors "y" and "r" -> as "p" represents an offset from the true "y" line).
________________________________________________
Question: Consider the graph:
I have the vectors of the black and blue lines, but I need the vector of the red line. (Notice that they are three different lines)
_______________________________________________
If it is impossible to gather this corresponding data-points from the spline function "csaps", is there another way of obtaining this data(another spline function - While still being able to specify a smoothing parameter "p")? Maybe obtaining a "spline formula", and then by inserting the "x" vector obtain the corresponding spline data?
Thank you!

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2020-8-28
For that purpose I used something like this:
y_smoothed = fnval(pp, x);
If you check out the documentation for Spline postprocessing you will find more information and additional utility functions.
HTH

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spline Construction 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by