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.
Help with vector-valued (curved) splines
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
Réponses (1)
dpb
le 10 Mar 2015
Modifié(e) : dpb
le 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.
Voir également
Catégories
En savoir plus sur Splines dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!