From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fitting formula: replace parameter names by real values

Solved!
Go to solution

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

 

 

edit_fitting_formula.JPG

0 Kudos
Message 1 of 9
(3,179 Views)

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
(3,171 Views)

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:

ReplaceFormula.png

 

I think the formula functions in LabVIEW allow you to replace formula parameters with their values:

Formula.png

 

Converting your string to an array of bytes (binary data?) doesn't make any sense.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 9
(3,164 Views)

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

 

 

edit_fitting_formula_context.JPG

0 Kudos
Message 4 of 9
(3,157 Views)

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.

 

 

edit_fitting_formula_search_for_solution.JPG

0 Kudos
Message 5 of 9
(3,155 Views)

Here is a solution that works.

 

Create_Function_String_from_Parameters - solution.png

0 Kudos
Message 6 of 9
(3,147 Views)
Solution
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
(3,143 Views)

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
(3,138 Views)

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.

 

edit_fitting_formula_search_for_solution (1).JPG

0 Kudos
Message 9 of 9
(3,128 Views)