Using cubic splines to fit data
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have a quite involved code for fitting cubic splines to data. I have noticed something odd and wondered if anyone had experience with this. For horizontal data, the spline fits extremely well, however for data within a small x range and large y, i.e. a series of vertical points, the spline is very odd! I have attached two images, first the data set and next the resulting fits.. Any help would be appreciated.
0 Kommentare
Antworten (1)
John D'Errico
am 18 Okt. 2016
First of all, why are you writing cubic spline codes to fit data, if you don't really understand cubic splines, and the issues involved with them?
I'm not sure why I made this an answer, since you say nothing concrete about what EXACTLY you are doing. There are lots of ways you can fit a spline to data, and the data that you have is nothing I would ever decide that a spline would be a good choice for. Do you presume noise in the fit? Is this an interpolating spline? (Why would you do that, EVER? But people do.)
Are you fitting the horizontal lines as separate functions, thus y as function of x for each horizontal set of points? Are the vertical lines fit as x as a function of y? If not, then why not? If you are trying to fit a spline through essentially vertical data in the form of y(x), you should realize that is an insane thing to do. (Sorry but it is.) Or are you somehow trying to fit all of these points at once? (How can I guess what you're doing wrong, when you say nothing?)
The fact is, there are spline codes out there. You would do far better to learn to use an appropriate spline code before trying to write your own. As it is, I'm not at all sure why you are trying to use splines on that data at all.
4 Kommentare
John D'Errico
am 18 Okt. 2016
Bearbeitet: John D'Errico
am 18 Okt. 2016
You did post the data as a figure, so I can extract the data. I think I can figure out how to employ gridfit to solve this problem...
open Fibres.fig
H = get(gca,'children');
x = H.XData;
y = H.YData;

I guess the question is, before I go further, how much of the variability in this data do you need to follow? What is your eventual goal? For example, do you want to turn this into a set of 4 slightly curvy-edged rects? Or would it be sufficient to simply replace those noisy lines with straight edges, though not necessarily meeting at right angles? So those nominal squares might turn into general 4 sided polygons?
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!