04-06-2016 07:33 AM
Hello,
After finding parameter values in fitting formula I need to replace parameter names by real values found by fitting algorithm.
For example in the snapshot below I need to replace a, b, c by real values (e.g. 2.346878, -12.4589, 8.0012) in order to use this formula for resolving nonlinear equation.
Transforming formula string into array of bytes seems to be quite dufficult because replacements have different size (e.g. a have to be replaced by 2.346878).
Does exist some smart solution for such problem.
Thanks
Solved! Go to Solution.
04-06-2016 07:44 AM
Can you provide the entire fitting routine? Generally if you are fitting a formula, you have the formula that you are evaluating, and it stays in "string" format. It seems odd (and possibly wrong) to change it to an array of bytes. Do you know about Formula evaluations? [I've not used them, myself, and don't particularly like going from compiled LabVIEW code to interpreted Matlab-like code ...]. Show us the routine-in-context, please.
Bob "Answer Analysis reveals that the Question is Wrong" Schor
04-06-2016 07:53 AM - edited 04-06-2016 07:54 AM
Use the 'search and replace string' function. Convert your numbers to a string and find 'a' and replace with the string representation of your number. This should get you started:
I think the formula functions in LabVIEW allow you to replace formula parameters with their values:
Converting your string to an array of bytes (binary data?) doesn't make any sense.
04-06-2016 08:07 AM
Hello Bob,
Here is context:
04-06-2016 08:11 AM
Thanks Sam,
I try to find a solution using For loop (please see the image below), but for the moment didn't find how properly apply the cluster with parameter names a, b, c.
04-06-2016 08:28 AM
Here is a solution that works.
04-06-2016 08:40 AM
Or even better ... the list of parameter names also can be extracted:
04-06-2016 08:45 AM
Did you notice the Scripts and Formulas sub-Palette on the Mathematics Palette? I believe these are the functions that the LM Algorithm uses to evaluate your function, so you might as well use them, too. They'll take the function you've already define, and the X array (as an array of Dbls) that you've already defined. I think this is what NI assumed you would do ...
Bob Schor
04-06-2016 09:13 AM
Bob,
I'm not sure that I properly understood your suggestion.
From the Script and Formulas sub-palette I use Find All Zeros function (from Zeros sub-palette) in order to find crossing points of fitted line with threshold (below the extraxt from final realisation).
For fitting I use Nonlinear Curve Fit (from Mathematics/Fitting sub-palette) that does properly its job.