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:

Solved!
Go to solution

Fitting formula: replace parameter names by real values

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

Message 1 of 9
(3,179 Views)

Re: Fitting formula: replace parameter names by real values

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

Message 2 of 9
(3,171 Views)

Re: Fitting formula: replace parameter names by real values

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
(blog)
Message 3 of 9
(3,164 Views)

Re: Fitting formula: replace parameter names by real values

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

Message 4 of 9
(3,157 Views)

Re: Fitting formula: replace parameter names by real values

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.

Message 5 of 9
(3,155 Views)

Re: Fitting formula: replace parameter names by real values

Here is a solution that works.

Message 6 of 9
(3,147 Views)
Solution
Accepted by topic author Pavel_47

Re: Fitting formula: replace parameter names by real values

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

Message 7 of 9
(3,143 Views)

Re: Fitting formula: replace parameter names by real values

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

Message 8 of 9
(3,138 Views)

Re: Fitting formula: replace parameter names by real values

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.

Message 9 of 9
(3,128 Views)