06-16-2021 07:18 AM
Hi
I am trying to use a non fitting procedure with constraints (either LM or TRDL), like here.
It is working OK but the function is defined at edit time, saved in a VI, and wired a reference to the fit subvi.
For my case I need to select the function at run time (over 100 possibilities, and I do want to write over 100 vi functions at edit time). I can calculate this function at run time but I don't know how to define f(x,a) at run time ?
thanks for any clues
Solved! Go to Solution.
06-16-2021 07:30 AM
Hi nitad,
@nitad54448 wrote:
For my case I need to select the function at run time (over 100 possibilities, and I do want to write over 100 vi functions at edit time). I can calculate this function at run time but I don't know how to define f(x,a) at run time ?
There is "VI name" input shown in your image, so you can easily select that function/VI you need at runtime.
What exactly is the problem? Do you want to know the VI names/paths when you call the OpenVIReference function?
06-16-2021 07:58 AM - edited 06-16-2021 08:01 AM
Hi
Sorry if it not clear : I know that I can add vi name at run time (I do it at present with several vis). This vi must be created before running the program, .. I want to be able to fit a run time user defined function, without creating a vi before running the program.
Let's suppose a program in which the user is asked to write a function to fit, say :
aX^2+bx^3
(and other users will write other functions...).
I can write a sort of interpreter to execute the function, without having to create the vi.
Not sure if it s clear, there was an error in my initial message : "and I do NOT want to write over 100 vi functions at edit time"
06-16-2021 08:11 AM
Hi nitad,
@nitad54448 wrote:
Not sure if it s clear, there was an error in my initial message : "and I do NOT want to write over 100 vi functions at edit time"
Well, this changes the whole meaning of your first message…
@nitad54448 wrote:
I can write a sort of interpreter to execute the function, without having to create the vi.
LabVIEW also comes with "formula parser" functions: see the Math -> Scripts&Formulas -> Formula Parsing palette…
You might try to incorporate those functions into your fitting function, but be warned: the parser is not made for fast execution!
06-16-2021 08:19 AM - edited 06-16-2021 08:21 AM
The formula parser vi (a string for a formula) does not do a constrained fit, does it ?. For the "regular" vi LM the problem is that I do not know how to do it (i.e. if I do not connect a ref to an external function the vi won't execute)
N
06-16-2021 08:35 AM
Hi nitad,
@nitad54448 wrote:
The formula parser vi (a string for a formula) does not do a constrained fit, does it ?.
The formula parser parses string formulas, it does no fitting…
But you wrote you want to parse (kind of) arbitrary formulas for the fitting - and that is what the parser does!
06-16-2021 08:43 AM
Sorry, still does not answer my initial query (I know how to parse the formula), but I still need to wire a reference to a vi defining f(x,a) which I do not have (and I can not create beforehand because there are >100 functions).
06-16-2021 09:20 AM
Hi nitad,
you can create one VI for the VI reference definition in the fitting routine.
That one VI could use the formula parser internally to calculate all possible user input formulas…
Again: the parser functions are rather slow, so the fitting will be slow…
06-16-2021 09:49 AM
OK, I see... you mean I can write a formula parser in the f(a,x) ? if this is doable, then ok (thanks).. I don't care much about speed (as a student, I used to do deconvolutions in Basic on a Spectrum ZX,.. 48 kb of RAM 🙂 )
thanks
06-16-2021 10:05 AM
I was looking at your solution and still have a problem... this is a static vi, there is no input to give a specific formula to parse... this vi is read by the LM fit vi but there is no run time update to an entry for this vi. Please give me an example if you think I am wrong.