Showing results for 
Search instead for 
Did you mean: 

Fitting formula: replace parameter names by real values

Go to solution



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.






0 Kudos
Message 1 of 9

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

0 Kudos
Message 2 of 9

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.

LabVIEW Champion, CLA, CLED, CTD
0 Kudos
Message 3 of 9

Hello Bob,


Here is context:

  • fitting formula is described in Fitting Model (also showed in my previous post)
  • The values of a, b and c are found in best fit parameters array
  • I need to edit Fitting Model formula ((1). replace a, b, c by real values and (2). add some constant)
  • Then the edited formula I want to apply to Find All Zeros block




0 Kudos
Message 4 of 9

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.




0 Kudos
Message 5 of 9

Here is a solution that works.


Create_Function_String_from_Parameters - solution.png

0 Kudos
Message 6 of 9
Accepted by topic author Pavel_47

Or even better ... the list of parameter names also can be extracted:


Create_Function_String_from_Parameters - solution (1).png

0 Kudos
Message 7 of 9

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

0 Kudos
Message 8 of 9



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.


edit_fitting_formula_search_for_solution (1).JPG

0 Kudos
Message 9 of 9