3D curve line fitting

조회 수: 2 (최근 30일)
Tyler
Tyler 2012년 3월 7일
Hi all,
My basic question is this. I have a set of data in 3D space that makes an approximate ellipse ring, with a few bends and noise. Is there an easy way to connect the points in a smooth way to make a nicely connected ring?
I created this simple code to represent what my data may look like.
%Create X and Y based on ellipse equation
x = -2:.1:2;
xnoise = (rand(1,81)-0.5)/10;%Generate small noise in x
y = sqrt(1-((x.*x)/4));
ynoise = (rand(1,81)-0.5)/10;%Generate small noise in y
x = [x(1:end-1) flipdim(x,2)];
x = x+xnoise;
y = [-y(1:end-1) y];
y = y+ynoise;
%Create Z using sine
s = 0:2*pi/80:2*pi;
z = sin(s);
znoise = (rand(1,81)-0.5)/10;%Generate small noise in z
z = z+znoise;
%Plot data field
plot3(x,y,z,'o')
Keep in mind that my knowledge of Matlab is limited and I would like a solution that can be utilized in coding as opposed a toolbox function. Thanks in advance!

답변 (1개)

kedija
kedija 2013년 8월 6일
편집: kedija 2013년 8월 6일
I asked the same question and get a nice answer though it has past a year since you ask it might help others to post the answer here.
just append the following at the end
hold on;
d= [x;y;z]';
[th, r, z] = cart2pol(d(:,1),d(:,2),d(:,3));
[sr, idx] = sort(th);
sd = d(idx,:);
plot3(sd(:,1), sd(:,2), sd(:,3))

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by