Cubic smoothing sline for trajectory approximation

6 views (last 30 days)
How does it work the csaps function and its variations ?
I need simpler explanations and examples if it's what I need for approximation of multiple trajectories in order to get a single nominal one.
Thks

Answers (1)

Raunak Gupta
Raunak Gupta on 3 Oct 2019
Hi,
The Cubic Smoothing Sline is used for fitting a curve to the noisy data. As it is mentioned that there are multiple trajectories involved, I am assuming all represent the same path but with noise in each trajectory. Cubic Smoothing Spline will give a cubic polynomial between successive datapoints based on weightage given to error measure and roughness measure parameter.
I would suggest taking the mean of all datapoints across the trajectories so that only one trajectory remains. Then this trajectory’s path may be calculated with csaps. You may find the following minimum working example helpful.
% Lets assume we have 7 trajectories with 100 datapoints each.
% For example datapoints can be generated using randn
trajectories = randn(100,7);
% Taking mean across the trajectories (that is 2nd dimension) will give a single trajectory
trajectory = mean(trajectories,2);
p = 0.1; % define the error measure weightage (Give path matching closely with datapoint for high value of p)
% p must be between 0 and 1.
x_data = linspace(1,100,100); % Just to have 2D sense of trajectories
path = csaps(x_data,trajectory,p);
fnplt(path); % show the path
% Here path is a structure which contains the polynomial coefficient between each successive pair of datapoint.

Community Treasure Hunt

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

Start Hunting!