Splines: How to find vector/array from smoothing line (function - csaps), or another function (still using a smoothing parameter)?
8 views (last 30 days)
Show older comments
Sean Combrink
on 25 Aug 2020
Commented: Sean Combrink
on 28 Aug 2020
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!
0 Comments
Accepted Answer
Bjorn Gustavsson
on 28 Aug 2020
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
More Answers (0)
See Also
Categories
Find more on Spline Construction 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!