LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please help on this Lev-Mar problem

Hi,

I have two acquisition data sources that need
to be fitted. Then the fitted parameters are
passed along with data for further processing.

As the data is heardware generated, I made a
similar 'signal generator' to present very closely
the problem.

===Please see the attached vi file===

As you can see, these two Lev-Mar's function
/ derivatives are obviously different. We can edit
the fuction / derivative node. But the problem
is that when one is edited, the other changes too.
Anyways, we can NOT have two different functions.

My question is: How to have two different function
/ Deveritives here?

By the way, how to replace the MatLab box into
function node in my attached example?
I can 'wire' the out
put to next if it's a
function node. It says the type of variables are
different (output is a real instead of array).
0 Kudos
Message 1 of 5
(3,131 Views)
You have a few options for multiple function/derivatives.

1. If you can express the model functions using the formula string syntax, then you might consider using the "Levenberg Marquardt.vi". Unfortunately the Levenberg-Marquardt.vi does not allow the specification of the derivative of the model function and always uses numerical derivatives. It is also somewhat slower than the "Nonlinear Lev-Mar Fit.vi".

2. You could also save a copy of the "Nonlinear Lev-Mar Fit.vi" using a different name, and also the "Lev-Mar ABX.vi" and "Target Fnc & Deriv Nonlin.vi" with different names. Then you would have a different set of VIs to implement the curve fitting on two different models. This is ugly, but would work.

3. You could modify the "Nonlinear Lev-Mar
Fit.vi", "Lev-Mar ABX.vi", and "Target Fnc & Deriv Nonlin.vi" to accept/pass VI references. The "Target Fnc & Deriv Nonlin.vi" would then perform a call by reference to a VI that you wrote implementing the current model function.

To replace the Matlab script node place the formula node inside a for-loop. The for-loop will auto-index the x and t arrays, and auto-build the y-array.
0 Kudos
Message 2 of 5
(3,131 Views)
Hi:

Thanks, you made the point.
Should or shouldn't I check the box:
"Save a copy without updating the callers"
for every vi?
0 Kudos
Message 3 of 5
(3,131 Views)
Here are a few postings which you may want to look at:
How to have two diffrent Lev-Mar blocks in one vi?
Two nonlinear fitting's function in one
You might want to see if those help. If you have already seen these, I would suggest adding questions and comments to those postings to keep them all in one place.
J.R. Allen
0 Kudos
Message 4 of 5
(3,131 Views)
I would recommend first saving a copy the Nonlinear Lev Mar Fit.vi. For this "save as" operation it doesn't matter if the check box "Save a copy without updating the callers" is selected or not. With this new copy of Lev Mar open, then open the subVIs that need to be modified (Lev Mar abx.vi etc.). For each subVI perform a "save as" to a new name and don't select the check box. The only callers that will be updated are those in memory, which in this case will be the new or second version of the Lev-Mar VI.

I also thought of a different approach that you might be able to use. You could implement both models in the Taget Fnc & Deriv Nonlin.vi, with each model in a different case of a case structure. Make the case selectable using a boolean or a
n enum, and propogate the selector up through the call chain to the top level. If you wanted to avoid changing the VIs that ship with LabVIEW, then make the selector a global variable, and place the two calls to Nonlinear Lev Mar Fit.vi in a sequence structure with the global variable set in the same frame of the sequence to select the desired problem.
0 Kudos
Message 5 of 5
(3,131 Views)