how can i work with the coefs of cscvn?

8 vues (au cours des 30 derniers jours)
Timon Niedecken
Timon Niedecken le 6 Juin 2018
Commenté : atharva aalok le 29 Août 2022
Hi there, I use cscvn() from curve fitting toolbox to get a natural spline for n points. n > 1000 in my specific case. The result is a (2*n)x4 double array for the coefficients and an break array. Now i want to calculate the length and the curvature(t=t0) of the spline. I know there are some formulae for that, but i dont know how to combine the coefficients for each spline section. i tried to understand it with
edit cscvn
but failed :/

Réponses (1)

Unai San Miguel
Unai San Miguel le 9 Juil 2018
There is no need to use the coefficients of the function, because the Curve Fitting Toolbox provides with functions to derive and evaluate the spline functions (curves).
The output of cscvn is a curve from R to R^d, being d the dimension of your points ([d, n] = size(points)|). The rth-derivative of that curve can be obtained with fnder(crv, r). It is also a spline function which can be evaluated with fnval(·, t) at any point you want (in the domain of your curve). So, if crv = cscvn(points), then the first derivative at t0 is fnval(fnder(crv,1), t0), the second derivative is fnval(fnder(crv, 2), t0) and so on. With these and the formulas from differential geometry of curves you can calculate the curvature of the spline.
To calculate the length of the spline you have to do the integral of the norm of the derivative
Dcrv = fnder(crv);
crvlength = integral(@(x) fnval(@(tau) sum(fnval(Dcrv, tau).^2), 1).^0.5, crv.breaks(1), crv.breaks(end));
  1 commentaire
atharva aalok
atharva aalok le 29 Août 2022
How can I make the curve smoother and also evaluate the curve for a given set of x values?
Please have a look at this question.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by