07-17-2007 05:45 PM
07-18-2007 09:14 PM
07-19-2007 12:04 PM
07-19-2007 12:23 PM - edited 07-19-2007 12:23 PM
You are almost there. Don't use any other inputs in the model!
Simply convert the cluster with the extra paramters to a variant (in the main program) and feed it to the "data" input.
Inside the model, you need to convert it back to the cluster, using a diagram constant of the cluster as type (see image).
Message Edited by altenbach on 07-19-2007 10:23 AM
12-07-2015 03:08 PM
Hi Altenbach,
I am new with labview and trying to use the nonlinear curve fit vi. I have a general question on this vi: what is the purpose of data wiring option? I understand it needs a reference model, but why data? I have read through the examples from NI and found most of them do not have data option wired?
Many thanks,
John
12-07-2015 03:58 PM - edited 12-15-2015 12:54 PM
Sometimes the model requires aditional information, so the data variant is just a generic mechanism to relay that information from the toplevel to the model subVI. Yes, for simple models it is typically not used but it is convenient to have it.
For example in this demo, I allow the user to select which paramters to fit and which ones to keep fixed during fitting (advanced model). If some parameters are held fixed, they are not available at the [a] input, but the model still needs to know them. In this particular case, the variant contains an array of all parameters (fixed and variable) and an array of indices indicating which ones to substitute with the variable parameters from [a] for the model calculation. Without that, you would need to write a gigantic number of different models (combinatorial explosion!), one for each possible combination of parameter selection, hugely complicating the code.
In another example, you could also place an enum into the variant and use a case structure inside the model to switch between differently coded algorithms (code A, code B, code C e.g.) for performance comparison. It could be a boolean to decide if it should explicitely calculate partial derivatives inside the model or let the fitting routines do it externally. (e.g. to validate if the partial derivative calculations are actually correct).
In some of my examples, I provide a huge kernel matrix needed for the model calculation. My data variant typically contains a cluster of 5-10 elements.
There is an infinite number of uses for the data variant input. 😄
(You could of course provide the extra data via global or shared variables or an action engine, but that makes it very dangerous because the values could be changed from elsehwere while fitting is in progress.)
12-07-2015 05:46 PM
Thank you so much Altenbach for your comprehensive answer, which helps me understand this data variant quite a lot. And thank you for continuously working on this nonlinear curve fitting vi. It is so useful.
John
12-15-2015 11:58 AM
hi Altenbach,
I have another question on this nonlinear curve fit. That is:
12-10-2015 04:46 PM
I found one disagreement between Numerical Recipes and LabVIEW help on covariance matrix definition in Nonlinear Curve Fit VI.
In Numerical Recipes, the covariance matrix C is the inverse of the curviture matrix Alpha and Alpha is defined as half of the Hessian matrix D. In Numerical Recipes, D is defined as the second derivative matrix of the chi^2 merit function, at any parameter. Therefore, C = 2 D^-1.
On the other hand, LabVIEW help gives an equation C = (1/2) D^-1. The definition of D is given by the help: "where D is the Hessian of the function with respect to its parameters". I feel the definition of D in LabVIEW is not quite clear.
Could you help us on this factor of 4 difference on this covariance matrix definition?
Many thanks,
John
12-15-2015 12:05 PM
12-15-2015 12:29 PM
Thanks Altenbach. I will tried to find them when I get some time.
John