fitting a curve on 3d data
9 views (last 30 days)
Show older comments
i have 3d data and I have plotted it using
scatter3(data(:,3),data(:,1) ,data(:,2));
I want to plot a curve along this 3d data, something like
Also how once i have plotted i want to extend the curve and get the x and y points (data(:,1) and data(:,2)) till my z points (data(:,3)) becomes 0. z usually starts from 35 and goes till 128. once the curve is fit i want to know the x and y points corresponding to z(0:34). Uploading the data.mat.
4 Comments
Answers (2)
John D'Errico
on 1 Jan 2018
Edited: John D'Errico
on 1 Jan 2018
UGH. If I understand you, this curve has a set of points that follow no known model, but you want to fit them, in 3-D. So this becomes an errors in variables kind of thing, but with no known model, what must be effectively a spline is the only thing that makes sense here.
I think, if I understand what you said, that those points that are not on the curve are identifiable (and can thus be segregated from the fit) have z==0. So at least you know which points do not belong on the curve.
That first part of the curve seems to be pretty linear to me. Then there is a fairly sharp break into a curved segment. And you are telling us that you now want to extrapolate that curved segment over a moderately significant distance? Sigh. Why do I want to insert Mark Twain's comments on the dangers of extrapolation here? Worse, this is also moderately noisy data?
That is, when you use a model that can fit a curved segment there, the fit at the end (and any extrapolation that you do) will be primarily based on the last few points on the curve. So if you were able to put confidence limits around the extrapolated curve near the end, they would get very wide very quickly.
Do you know where/when the break occurs?
I might also note that it LOOKS like there are linear segments on this curve. Thus the curved region even seems to be composed of approximately linear segments. I might guess that curved region is three linear segments. But finding break points, even in a piecewise linear, but continuous curve, in three dimensions, with errors in variables is not a trivial thing.
Do you know some reason why the curve appears to have vaguely linear segments? That seems to be suggested, given that is what you drew.
Did I say UGH? Is this something you need to do ONCE? Or is it something you need to do automatically for multiple sets of data? (Please don't tell me the latter is the case.)
You have not provided the data itself. That makes me worry/wonder if this is something you will be doing multiple times. (Edit: oops, I see you did attach the data!)
For example, if I were needing to do this ONCE, I might artificially pick the breaks by eye. Once I had those points, I could at least use the last segment to fit a straight line using an SVD to do the errors in variables fit, then extrapolating that line.
3 Comments
John D'Errico
on 1 Jan 2018
It does not matter what variable is plotted on which axis. That does not improve the data or make the problem simpler.
Image Analyst
on 1 Jan 2018
I thought I already answered this in your prior post. Basically you parameterize the 3 coordinates and do a fit, cleaning the data beforehand if desired. What was wrong with that solution, except that you didn't want the fitted red line to actually be plotted, which is an easy thing to get rid of?
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!