LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

constrained LM fitting with run-time function

Solved!
Go to solution

Hi

I am trying to use a non fitting procedure with constraints (either LM or TRDL), like here.

 

nitad54448_0-1623845820235.png

 

 

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

0 Kudos
Message 1 of 11
(1,831 Views)

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?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(1,821 Views)

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"

0 Kudos
Message 3 of 11
(1,810 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(1,789 Views)

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

0 Kudos
Message 5 of 11
(1,781 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(1,764 Views)

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).

0 Kudos
Message 7 of 11
(1,760 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 11
(1,755 Views)

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

0 Kudos
Message 9 of 11
(1,750 Views)

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.

 

0 Kudos
Message 10 of 11
(1,746 Views)