Help with vector-valued (curved) splines

1 次查看(过去 30 天)
I'm trying to spline data points that overlap(x-values may have more than one associated y-value) to create circles/curves and I found the Vector-Valued Spline code on MathWorks and I'm having trouble implementing it for my own data.
Above is what occurs when I use the exact same code on my own data and I do not know why.
Below is the mock-up I've created my manually selecting points of what I wish to happen with the splining feature.
I've attached my data to this post. Can anyone point me in the right direction?
  1 个评论
Brian Vu
Brian Vu 2015-3-10
I have attempted to reduce the number of data points (by taking every 3rd or so point) and the same problem occurs. I believe it may have to do with the way the data is organized but I am not sure how to proceed.

请先登录,再进行评论。

回答(1 个)

dpb
dpb 2015-3-10
编辑:dpb 2015-3-10
The data in the example forms the boundary from one "fin" at the upper left and follows the path around to the last point that (nearly) closes the figure. Does your data follow such a regular pattern or are the two nearby 'x' values of the upper and lower boundaries adjacent (I'm guessing)? The algorithm will need the former, not the latter to have any chance of following the curve; it expects the curve to have it's points in a sequence along the path.
To see the difference, try the following if copy the sample data--
>> [xx,ix]=sort(x); yy=y(ix); % sort the data by x values
>> plot(x,y) % plot original
>> hold on
>> plot(xx,yy,'rx:') % now add the sorted
See how the points are now in order jagged between the upper and lower smoother segments? That's what it appears your case is w/ all the scribbling between the two.
Rearrange the data in a sequence as is the sample and I suspect all will be well...
ADDENDUM
I see your data is attached...indeed, looking at it it is precisely what I suspected was the case. I don't have a good way to automate sorting it out but it's pretty easy to see which does/doesn't belong visually. A diff operation on the y-values to find large discontinuities could probably be coded to do it if you have multiple ones of these and can't generate the data otherwise in the needed ordering.
  1 个评论
Brian Vu
Brian Vu 2015-3-10
Looks like I have to re-order that data, I'm currently looking into functions that calculate the euclidean distances between points in a data set. I hope to choose one (x,y) coordinate as the starting point and reorder the data by looking at the nearest neighbour to each point.
Perhaps I will open a topic specifically with reordering the data in mind.
Thanks for your reply.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Splines 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by