Using csaps (or similar) to create a 3D smoothing spline

14 ビュー (過去 30 日間)
Laurence hutton-smith
Laurence hutton-smith 2015 年 5 月 28 日
回答済み: Bryan Howell 2016 年 10 月 31 日
I have a series of 3D points and am looking to create any sort of smoothing spline, I was hoping to use scaps, but it only seems to take in 2D data, can anyone help with this? Is there for instance a way to input 3D data into it or another function I could use?

採用された回答

Dasharath Gulvady
Dasharath Gulvady 2015 年 5 月 29 日
編集済み: Dasharath Gulvady 2015 年 5 月 29 日
You can do this using "csaps" function. However the trick is to make "z" your independent variable.
[pp,p]=csaps(z,[x;y]);
val=fnval(pp,z);
figure,plot3(x,y,z);
hold on,plot3(val(1,:),val(2,:),z,'r-')
grid on
  1 件のコメント
Laurence hutton-smith
Laurence hutton-smith 2015 年 5 月 30 日
Thank you, this is extremely helpful.

サインインしてコメントする。

その他の回答 (1 件)

Bryan Howell
Bryan Howell 2016 年 10 月 31 日
The accepted answer is quite elegant but doesn't work for all types of trajectories, especially those where the z value is relatively constant.
An alternative approach is to fit a smoothing spline for each dimension and then combine. For example...
% given data in a point matrix, xyz, which is 3 x number of points
[ndim,npts]=size(xyz);
xyzp=zeros(size(xyz));
for k=1:ndim
xyzp(k,:)=ppval(csaps(1:npts,xyz(k,:)),1:npts);
end
This approach is also not a panacea but can address some cases where the first answer might fail.

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by