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 中查找有关 Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by