Curve (Line) Fitting in 3D
Afficher commentaires plus anciens
Hi, I've noticed John D'Errico answering a few of these questions but the polyfitn doesn't seem at first trial to do what I want. But I have some data in x,y,z coordinates. See attached for coordinates. I have manually selected x,y from images based on z = [0:2:100]. However I'm not sure how to fit a curve to this in 3D in order to remove error due to manual selection.
2 commentaires
Star Strider
le 27 Avr 2017
What function do you want to fit to your data?
Alec Day
le 1 Mai 2017
Réponse acceptée
Plus de réponses (1)
Steffen B. Petersen
le 16 Déc 2017
0 votes
I read your question such that you have a large number of points in 3D (x,y,z), and you want to fit a line through these points.
You should principal component analysis : First you 'whiten' your data by subtracting the mean of you data from each data point. Let us call your mean 'myaverage' - this is point in 3D space at the center of your data. Let us call the whitened data (X,Y,Z)
(X,Y,Z)=(x,y,z)-myaverage
Second you use pca to extract the coefficients - in this case a 3x3 matrix where the first column is the vector that has the largest varians over your dataset.
[coefficient]=pca(X,Y,Z);
You can now draw a line through your datapoints using
mypoint=myaverage+t*coefficient(:,1)
by varying the parameter t you find the points for your fitted line. From this point off you may want to compute the RMS deviation - but that probably is not your problem.
Regards
Steffen
1 commentaire
Sarvesh Singh
le 15 Fév 2018
Modifié(e) : Sarvesh Singh
le 15 Fév 2018
Hi Steffen,
I'm trying to implement this. Can you please elaborate what this parameter 't' is and what should be its typical value for the best fit. Also is it possible to fit any other curve instead of line using this method?
Regards,
Sarvesh
Catégories
En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

