LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

nonlinear fit model function

Solved!
Go to solution

Hi, I'm trying to use a custom fit - fitting modified error function to the provided data. 

For the nonlinear fit I need a model fitting function VI, which I created from template (attached LM_erf_model.vi). 

I have a problem connecting the reference for the attached function to f(x,a) input of the Levenberg-Marquardt

nonlinear fit VI - I can't create the proper reference and end up with

 '

You have connected a refnum of one type to a refnum of another type and both types are members of some class hierarchy, but there is neither a simple up cast nor type cast between the two classes. 

'

 

What's the proper way of creating the reference for this model function to be used in marquardt test .vi?

 

Regards

Michal 

Message Edited by mdwuznik on 01-29-2009 01:07 AM
Download All
Message 1 of 10
(4,802 Views)
Solution
Accepted by topic author mdwuznik

SOLVED!

 

Wiring proper type to 'open VI reference' input solves the referencing problems.

Still need to find what causes the singularity of the equation set... 

Message 2 of 10
(4,790 Views)

It is typically much easier to place a static VI reference on the diagram, then

  1. right-click...browse for path...point to the model VI
  2. right-click the static reference and make it strict (red star)
  3. hook it up the the nonlinear fitting VI, ignore the coercion dot. 😉

 

Your model functions is overly complicated. Index array is resizeable, so get the three parameters before the loop at once. No need to index the same element with every itreation of the loop. I would recommend not to use a formula express VI.

 

 

Do you have some typical data?

 

Message Edited by altenbach on 01-28-2009 05:50 PM
Download All
Message 3 of 10
(4,787 Views)
Also remember you MUST initialize the error shift register, else you would always start with an error if an earlier call to the subVI ended in error.
Message 4 of 10
(4,779 Views)

Thanks a lot for your help,

 

I figured out the fitting, I attach the working test version with very real-like data.

Instead of Express Formula I used the Mathscript field, which seems sooo slow...

 

Any insights on replacing that particular fit with sth faster? (I know, mathscript is not really a speed demon, though erf() is not that popular to be understood in 'formula string'...), and on the other hand I find calculating gaussian peak and integrating afterwards a bit on the cheating side (though I've done numerically worse things) . As for the example - I like the quality of fit very much, though I would appreciate some tenfold increase in speed 🙂

 

Regards Michal

Download All
Message 5 of 10
(4,748 Views)

For speed, you should use plain wires. 🙂

 

Also, your model VI is broken, it does not compile here. Yesterday, I made a quick rewrite and it seems to work fine with your new data. try it.

 

 

Message 6 of 10
(4,735 Views)

Here's a picture of the model and a fit of your data.

 

Message Edited by altenbach on 01-29-2009 09:25 AM
Message 7 of 10
(4,733 Views)

Hmm, 

I do not know why on some machines my vi complains about CDNC....vis for arithmetic. No problems with pure wires, though 

this reminds of pure assembler snippets in C.  As useful & speedy as ugly looking:).

The speed increase is moreless thousandfold. Yes, plain old wires are fast.

 

Kudos.

Michal 

Message 8 of 10
(4,716 Views)

My model VI was a bit hurried, so here's a probably slightly faster version. (e.g. we can eliminate the +1 at the end if we initialize the shift register with 1. Also, several opareations can be done on the scalars instead of arrays). There are probably further improvements possible.

 

Shouldn't make much of a difference, but cleaner is always nicer. 😉

 

Message Edited by altenbach on 01-29-2009 10:58 AM
Download All
Message 9 of 10
(4,705 Views)

No much difference when collecting the datapoints for 128 traces will take ~10 minutes (no, not wasting 99,99% of the time), and one fit takes 20 ms, which means 2 secs for all the traces :). Thanks anyway. 

 

 

 

Message 10 of 10
(4,690 Views)