106 views (last 30 days)

Akira Agata
on 24 Jul 2019

One possible straight-forward way would be like this:

Actually, spline interpolation seems to be better than cubic spline...

But if you want to use cubic spline, please use 'pchip' option, instead of 'spline'.

% Sample point

x = [1,6,2,5,3,1];

y = [4,1,6,4,1,1];

z = [9,5,1,5,1,2];

t = [1,2,3,4,5,6]; % Assumed time stamp

% Apply interpolation for each x,y and z

tt = linspace(t(1),t(end));

xx = interp1(t,x,tt,'spline');

yy = interp1(t,y,tt,'spline');

zz = interp1(t,z,tt,'spline');

% Visualize the result

figure

scatter3(x,y,z)

hold on

plot3(xx,yy,zz)

David Goodmanson
on 26 Jul 2019

Akira Agata
on 28 Jul 2019

Hi David-san,

Thank you for the clarification. Yes, as you mentioned, interp1(...'spline') and cubic spline (not-a-knot spline) is the same thing. I was just confused "piecewise cubic interpolation" and "cubic spline" when posting my previous answer.

Thank you again!

Sign in to comment.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/473087-how-do-you-calculate-a-trajectory-through-a-series-of-3d-points-using-cubic-splines#comment_728558

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/473087-how-do-you-calculate-a-trajectory-through-a-series-of-3d-points-using-cubic-splines#comment_728558

Sign in to comment.