fitting a curve on 3d data

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 comentarios

Matt J
Matt J el 1 de En. de 2018
The extrapolation that you get will depend very much on the model you select for the curve. I assume you have a model in mind? Why else would you have you departed from the initial model of the points as a line?
Akira Agata
Akira Agata el 1 de En. de 2018
Looking at you plot, several points are not on the fitting curve. Is it possible to ignore them when calculating the fitting curve ?
prashant singh
prashant singh el 1 de En. de 2018
@Matt the line was ok but it only covers like 10% of the data. I have a lot data like this the line wasn't as generalize solution as i thought it would be.
prashant singh
prashant singh el 1 de En. de 2018
@Akria Agata Yes its fine if we ignore the noisy part.

Iniciar sesión para comentar.

Respuestas (2)

John D'Errico
John D'Errico el 1 de En. de 2018
Editada: John D'Errico el 1 de En. de 2018

2 votos

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 comentarios

John D'Errico
John D'Errico el 1 de En. de 2018
Editada: John D'Errico el 1 de En. de 2018
Here is the data you have given us:
data =
252 694 36
249 686 37
253 669 38
252 671 39
250 663 40
250 655 41
247 654 42
248 644 43
250 633 44
246 632 45
243 623 46
249 615 47
247 610 48
244 602 49
247 591 50
242 586 51
242 584 52
248 570 53
244 568 54
244 560 55
240 557 56
242 550 57
242 541 58
245 532 59
244 525 60
242 518 61
246 514 62
237 504 63
191 1 64
184 2 65
173 1 66
169 2 67
168 2 68
174 1 69
182 2 70
245 447 71
238 444 72
239 435 73
241 428 74
238 423 75
239 416 76
238 403 77
238 400 78
235 387 79
243 385 80
238 381 81
236 370 82
231 364 83
232 356 84
233 342 85
231 344 86
230 335 87
233 325 88
235 313 89
233 306 90
229 299 91
234 283 92
225 252 93
231 230 94
225 200 95
228 185 96
233 174 97
231 161 98
224 151 99
225 139 100
229 130 101
241 120 102
230 115 103
234 108 104
235 98 105
228 91 106
230 82 107
231 79 108
224 70 109
228 59 110
227 51 111
229 45 112
226 39 113
227 24 114
237 19 115
226 17 116
222 5 117
218 2 118
211 3 119
209 2 120
205 1 121
207 1 122
202 1 123
199 3 124
196 1 125
195 3 126
262 1 127
So, not only is this an errors in variables thing, but it is a curve defined by points that are not even apparently connected in time. Only a loose connection exists, because there appear to be groups of points that ARE connected.
My headache is starting to get worse. Yes, this is early New Years day, but I don't drink, so that is not the issue. ;-)
Worse yet.
So the data you have attached is not the same curve as the one you show in the picture, and the noise appears to be significantly larger than it did for the curve you drew for us.
Multiple sets of data tells me this is a problem you will face multiple times, so you are looking for some sort of automatic solution.
SIGH.
prashant singh
prashant singh el 1 de En. de 2018
Editada: prashant singh el 1 de En. de 2018
To view the data, please switch the dimension to
scatter3(data(:,3),data(:,1) ,data(:,2));
Also you can ignore the noisy part .. i just want to fit some curve even if it covers like 50% to 60% of data. I have a lot other data like this and i want to find some generalised solution for that
John D'Errico
John D'Errico el 1 de En. de 2018
It does not matter what variable is plotted on which axis. That does not improve the data or make the problem simpler.

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 1 de En. de 2018

0 votos

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?

Categorías

Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.

Preguntada:

el 31 de Dic. de 2017

Respondida:

el 1 de En. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by