ellipse fitting from a plot in MATLAB

I have datapoints in text file which I have imported and ploted. Now I want to do ellipse fitting of that data. Can you please help me with that?

 Risposta accettata

Image Analyst
Image Analyst il 25 Mar 2021

6 Commenti

Thanks for your answer.
I already have data files.
here I have attached .m file and .txt file as well. Can you please suggest how can I do ellipse fitting in my code?
What do a and b represent? Why are they different lengths?
Your code doesn't seem to show any ellipses. What's going on?
a and b are the two waves one is sine and another is cosine
Are you sure you actually tried to adapt my demo? Anyway, it was rather straightforward and you just needed to add a call to fitellipse() at the end of your code. It's attached and produces this plot.
Sayanta Goswami
Sayanta Goswami il 31 Mar 2021
Modificato: Sayanta Goswami il 31 Mar 2021
Thanks a lot. I had seen the code but there was some issue with these two files that I have attached herewith.It is not giving Theta value correctly. Theta should come araound zero degree but it is giving 68 degree and 44 degree. Please help me.
I have attached google drive link for the files and the code that I was using.

Accedi per commentare.

Più risposte (1)

Matt J
Matt J il 31 Mar 2021
Modificato: Matt J il 31 Mar 2021
Theta should come araound zero degree but it is giving 68 degree and 44 degree.
Using ellipticalFit() in,
[X,Y]=deal( smoothX(jdx:jdx+200000,1),smoothY(idx:idx+200000,1) );
fitobj=ellipticalFit([X,Y].')
[hFit,hData]=plot(fitobj,{'Color','r','LineWidth',3},{'SizeData',2});
xlabel 'X'
ylabel 'Y'
legend([hFit,hData],'Fit','Data')
gives me and angle of about 79 degrees (or 11 degrees to the Y axis). I don't know how close to zero degrees you expected, but the tilt angle in your samples is very visible, so it couldn't be too close.
fitobj =
ellipticalFit with properties:
center: [-0.0156 -0.0130]
a: 0.5679
b: 0.4198
angle: 79.2091

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by