LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fit 2D data in to Circle

I have a 2D set of data and I need to perform circle fitting. The model for the fitting is the normal equation of a circle (x-a)^2+(Y-b)^2=R^2.

I was just wondering to see anyone has done it before in Labview environment.

Any help would be appreciated.

Message 1 of 30
(11,663 Views)

LV provides a VI that lets you fit your data to a sphere. Just use that VI with your Z-data = 0.

Ben

PS: I think I learned this from Christian.



Message Edited by Ben on 03-10-2008 02:21 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 30
(11,657 Views)

Thank you for quick response, I'll try it now.Smiley Happy

 

0 Kudos
Message 3 of 30
(11,655 Views)

Is that what you meant?

So, why doesn’t it work?

 

Could you have a look at the draft that I have attached.

0 Kudos
Message 4 of 30
(11,647 Views)
Your Z array is zero lenght, it needs to be the same lenght as the X or Y arrays! Just multiply e.g. the Y array by zero to generate the Z array.
 
To graph the best fit, you need to generate circle data based on (x,y) and r. Here's a simple draft how you could do it. (LabVIEW 8.5).
 
 
(The code would be quite a bit simpler of you would use complex data)


Message Edited by altenbach on 03-10-2008 01:33 PM
Download All
Message 5 of 30
(11,636 Views)
 
I can not really understand what you are tryning to do in these two part of code.
 
0 Kudos
Message 6 of 30
(11,627 Views)


Maryam hosseini wrote:

So, why doesn’t it work?


You should really make it a habit to place indicators on the error out terminals.
 
For example the "fitting on a circle" with a z array of zero lenght will give you -23033. Enter that in "help...explain error...":
 
Error -23033 (Analysis:  Vectors have different dimensions or empty vectors).
 
🙂
0 Kudos
Message 7 of 30
(11,627 Views)
0 Kudos
Message 8 of 30
(11,625 Views)


Maryam hosseini wrote:
I can not really understand what you are tryning to do in these two part of code.

On the left, I generate a unit circle with 128 points (this number could probably be much smaller) with center at 0,0 and radius=1. In order to calculate the circle based on the fitting result, we just need to multiply all points with r and then add x0 to all x and y0 to all y and graph them on top of the raw data.
 
We get a unit circle if we plot e.g. x=sin(t) vs. y=cos(t) for t=0 to 2pi. I'ts just plain old trigonometry. 😄
 
Of course you can calculate a circle from scratch based on the fitting results, but my method is more economical in a more typical application where we need to fit several times. You need to calculate the unit circle only once outside the loop and then scale it differently every time we fit new data inside a loop, for example.
 

 


Message Edited by altenbach on 03-10-2008 02:07 PM
Message 9 of 30
(11,620 Views)


Maryam hosseini wrote:
 
I can not really understand what you are tryning to do in these two part of code.
 


The attachment you posted is not a .png.  It is actually a very large bitmap that was given a .png extension.  It takes a long time to download a  3.7 MB file.  Please use MS paint to save it as a .png.
 
Also, if you want to put the image in the message, (please don't do this with monster sized images like the one you attached),  you have to attach the image and post the message first.  Then you can edit the message and put an image in the message whose path is where it resides on the NI server.  In this case,  http://forums.ni.com/attachments/ni/170/307641/1/circle-fitting.png  The image you pasted in came directly from your machine and looks like H:\My Documents\My Pictures\circle-fitting.png  I guess your personal directories that are mapped to your network server?  Since that path means nothing to us, you image shows up as a piece of paper with a red X in it.  Once you've posted, you can right click on the attachment link, select properties, and copy the network path off the dialog box.
0 Kudos
Message 10 of 30
(11,612 Views)