MATLAB: How can i Find the derivative of Spline Function

3d trackderivatives

Hello Everyone,
I made a 3D Track using spline function and i want to take the derivatives of the spline upto 3rd order .I used diff() and gradient function to take derivatives but results are not okay because it's for numerical differentiation.I need to find a way for piece wise polynomials.Can anybody help how can i do it.I have attached my code.Thank you.
Related Question