Interpolation of 3D point data

조회 수: 75 (최근 30일)
shellmcg
shellmcg 2016년 4월 19일
댓글: Adam Danz 2019년 12월 19일
Hello, I have a nx5 matrix where column 3, 4 and 5 are x,y,z 3D points respectively. I was wondering how I would interpolate (smooth) this 3D data. Many thanks
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 4월 20일
What properties does the curve need to have? Are you looking for a spline fit? A pchip fit?
shellmcg
shellmcg 2016년 4월 20일
Hi Walter, I was looking at a spline fit.

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2016년 4월 29일
편집: John D'Errico 2016년 4월 29일
You can use my interparc tool, as found on the file exchange. It is designed to solve exactly this problem, in 2 or more dimensions.
xyz = interparc(1000,x,y,z,'spline');
xyz will be a 1000x3 array, where each row is an interpolated point on the curve.
Of course, you can do the interpolation in other ways. If you want to do the work in MATLAB yourself in much the same way as you tried to do it:
t = [0;cumsum(sqrt(diff(x).^2+diff(y).^2+diff(z).^2))];
t = t/t(end);
ti = linspace(0,1,1000);
xx = spline(t,x,ti);
yy = spline(t,y,ti);
zz = spline(t,z,ti);
The above solution, which uses a cumulative piecewise linear arclength as the parameter for interpolation, deals more properly with points that are not uniformly spaced.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2016년 4월 20일
It looks to me as if you likely want a scattered interpolant.
  댓글 수: 2
shellmcg
shellmcg 2016년 4월 22일
편집: Walter Roberson 2016년 4월 22일
No I am asked to do a spline fit. Any suggestions?
This is all I got with errors
xx=linspace(matrix(1,3),matrix(end,3),1000);
yy = spline(matrix(:,3),matrix(:,4),xx);
zz = spline(matrix(:,3),matrix(:,5),xx);
Thanks

댓글을 달려면 로그인하십시오.


shellmcg
shellmcg 2016년 4월 28일
Figured this Question out
Inter_p= linspace(1,length(Data),1000); %create a array of points within the length of the data
xx=spline(1:length(Data),x,Inter_p); % use points created above to interpolate x,y,and z
yy=spline(1:length(Data),y,Inter_p);
zz=spline(1:length(Data),z,Inter_p);
  댓글 수: 1
John D'Errico
John D'Errico 2016년 4월 28일
편집: John D'Errico 2016년 4월 29일
I'm sorry, but this answer is just a poor way of solving the problem, presuming the points are somehow equally spaced. Use of a spline as was done here can cause some strange artifacts.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by