LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Curve fitting the integral of a gaussian

Solved!
Go to solution

Hi,

 

I have LabView 2013 I am trying to curve fit using the Lev-Mar non linear curve fitting vi but not sure how to proceed. From what I gather you can create a user defined model in the string but the help files only detail a second order polynomial of the form a1+a2*x+a3*x^2.

 

I have data that is the intensity of laser reflection on a sample, and when the laser moves over  metal marker the intensity increases. The metal marker has a knife edge beginning and so the intensity increase moving over the marker shows the gaussian shape of the beam and the intensity profile can be described using the integral of the gaussian shape.

 

Sorry if this problem has been posted before but I can't see it in the forums in a general enough way that I can understand as a new user. I essentially want to type a user defined model of the integral of a gaussian and feed it my data in the form (x,I) and have it give me the coefficients from which I can take the centre point as the edge position of the marker.

 

Thanks,

 

Paul.

0 Kudos
Message 1 of 8
(4,654 Views)

If you are having problems with your LabVIEW code, it really helps us to help you when you post your code.  Attaching the VI itself is the surest way to provide us something we can "poke at" and observe -- if you have multiple VIs or an entire Project, you can compress the folder they are in and attach the resulting .zip file.

 

Bob Schor

0 Kudos
Message 2 of 8
(4,623 Views)

Thank you, please find the VI and some sample data attached

Download All
0 Kudos
Message 3 of 8
(4,606 Views)
Solution
Accepted by topic author PaulHill

OK, I have a comment on the Code and a comment on the Data.  First, the code.  You are using a "Formula String", which means that you are asking LabVIEW to pretend that it is Matlab and can "interpret" a string to carry out the instructions you wish.  It would greatly surprise me if this worked, particularly with things other than simple polynomials.  Since this is LabVIEW (and not Matlab), write a VI to compute F(x, a) and explicitly put in the square root and erf functions you require.

 

In looking over the data, I must confess that I don't know what you are trying to fit.  I see a number of noisy what-look-like square wave pulses in X and Y, not occurring at the same time.  I'm guessing that you are interested in fitting something to the transition -- why not look for "large first derivatives" and (for example) find the midpoint between High and Low?  If you need more sophisticated fitting functions, you could at least narrow down the data set you send to your fitting function to include a small subset of points surrounding the transition.

 

Bob Schor

0 Kudos
Message 4 of 8
(4,600 Views)

Thanks I will try to make a vi with the functions as you mention. Would that then be fed in as a reference VI to the Lev-Mar non linear fit VI?

 

The data is intensity levels on and off a reflective metal marker as measured by a laser. When passing from on the marker to off the marker the intensity drops but the transition should be related to the beam shape and theoretically fitted using the integral of the gaussian that describes it. What I am actually trying to do is automate the process of detecting the location of these edges.

0 Kudos
Message 5 of 8
(4,592 Views)

@PaulHill wrote:

What I am actually trying to do is automate the process of detecting the location of these edges.


How precise do you have to be?  If we can assume that, say, X and Y represent the positions of the Laser and are stepping at a uniform rate, I'll bet you can do a very accurate estimate of the edges using a piece-wise linear fit (i.e. a straight line connecting two levels), which code you should be able to write yourself using "brute force" methods.

 

Bob Schor

0 Kudos
Message 6 of 8
(4,585 Views)

Thank you for your help so far, I may end up just doing another method of detecting the edges. In the meantime however I have created a reference model vi and connected it but the fit is only giving me a straight line :/. Any ideas?

 

Thanks,

Paul.

Download All
0 Kudos
Message 7 of 8
(4,538 Views)

Just to let you know, the model VI was working but with the data points being the inverse of the shape I wanted to fit it didnt work. When I flipped the data and tried again I was getting a sensible shape just the best fit coefficients arent very good, I will try to play with the initial parameters to see what I can do.

 

Thank you for your help.

Paul

0 Kudos
Message 8 of 8
(4,515 Views)