Help with vector-valued (curved) splines

2 views (last 30 days)
Brian Vu
Brian Vu on 10 Mar 2015
Commented: Brian Vu on 10 Mar 2015
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 Comment
Brian Vu
Brian Vu on 10 Mar 2015
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.

Sign in to comment.

Answers (1)

dpb
dpb on 10 Mar 2015
Edited: dpb on 10 Mar 2015
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 Comment
Brian Vu
Brian Vu on 10 Mar 2015
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!