01-28-2009 06:06 PM - edited 01-28-2009 06:07 PM
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
Solved! Go to Solution.
01-28-2009 07:41 PM
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...
01-28-2009 07:48 PM - edited 09-04-2013 04:19 PM
It is typically much easier to place a static VI reference on the diagram, then
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?
01-28-2009 08:13 PM
01-29-2009 07:03 AM
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
01-29-2009 11:16 AM
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.
01-29-2009 11:24 AM - edited 01-29-2009 11:25 AM
Here's a picture of the model and a fit of your data.
01-29-2009 12:23 PM
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
01-29-2009 12:57 PM - edited 01-29-2009 12:58 PM
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. 😉
01-29-2009 03:26 PM
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.