LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem: Fitting Lev-Mar with Error Function

Solved!
Go to solution

Hi everyone,

 

I have very little experience with LabVIEW and I'm trying for the first time to do some NonLinear Curve fit for some data I have.
I've searched in forums for almost a day and couldn't find what I need. The problems are:

 

1) I need to fit a function of the following type: P = Po/2 - Po/2*erf(sqrt(2)*(x-xo)/w) , where Po, xo and w are my parameters.

But in my error2.vi I cannot link my y=sqrt(2)*(x-xo)/w  variable of the erf function to the input, because the erf.vi does not accept 1D array as input and doesn't give that as output as well. The output thing is another problem, since the input of F(x,a) needs to be a 1D array.

 

2) I read about the Lev-Mar NonLinear CurveFit VI and I think I got what needs to be done. However, a I was having problems in wiring my Static VI Reference to the F(x,a) input in the Lev-Mar VI and it didn't give me a broken wire only when I made de Reference a "Strictly Typed VI Reference". What does that mean? Why did it only work with that?

I know these are some pretty basic doubts, but I've been trying to understand it for quite some time and couldn't get this done.

Thanks.

PS* The fitting function (subvi) is the error2.vi file.

Download All
0 Kudos
Message 1 of 9
(4,570 Views)

For the model, you need to start with the template mentioned in the help page (seems you did that). The model needs to be strictly typed, because the model subVI needs to match the required connector pattern exactly.

0 Kudos
Message 2 of 9
(4,557 Views)

Thanks!

And do you know anything about the use of "Error Function"? I found only a few references to it in the web and I don't understand how to make it work...

0 Kudos
Message 3 of 9
(4,547 Views)
Solution
Accepted by topic author Yuri94

Try this. Seem to work  just fine (LabVIEW 2013).

 

(don't try to graph the best parameters, graph the best fit output!)

 

Download All
Message 4 of 9
(4,544 Views)

@Yuri94 wrote:

And do you know anything about the use of "Error Function"?


The LabVIEW version is not polymorphic, i.e. it does not accept arrays, but only single x values. This means you simply need to wrap an autoindexing FOR loop around it to do it for all x values.

 

 

0 Kudos
Message 5 of 9
(4,539 Views)

Wow! Thanks so much, altenbach! It works perfectly!

 

I didn't know about the "Re/Im to Complex" for plotting graphs. Very useful... Thanks a lot!

0 Kudos
Message 6 of 9
(4,529 Views)

I am glad it works for you. Feel free to mark the most helpful answer as solution to the thread. 😄

0 Kudos
Message 7 of 9
(4,524 Views)

Hello,

I have the same problem with the fitting of the error function. I tried to open the vi's, but I'm using Labview 2011. So it's not possible to open them. Is it possible to upload the vi's for Labview2011 again? This would be great.

 

Thanks!

Andreas

0 Kudos
Message 8 of 9
(4,267 Views)

@Andreas_B wrote:

Is it possible to upload the vi's for Labview2011 again? This would be great.


Here you go!

 

 

Message 9 of 9
(4,255 Views)