11-06-2013 02:21 AM
Hi.
I am using the Nonlinear curve fit VI in order to fit data. The reference to the fitting model VI that I use is included in the attachment. You can see that I have some constants wired, like 4, 2500 and 1. I want to make this constants variables that I will change prior every curve fit, because actually in my problem this variables I know before the fit, and they are always changing, and at the moment this VI is just made for testing.
The problem that I have is that I can't enter this variable values from my main VI, where I also call the Nonlinear fit VI. The connection pattern of the refernce fit VI must be not changed in order to be recognized by the Nonlinear fit VI. I was trying to use the a array to transfer the variables, but if I use a, it recognize the variables as fitting paramters and it tries to fit them as well in the fitting procedure, and it gives me wrong results.
Any ideas how I can add the variables values?
Thanks a lot.
Kind Regards,
Nikola Todorovski
Solved! Go to Solution.
11-06-2013 02:55 AM
Hello Nikola,
First in general, you can remove the for loop with a iteration of 1 same for the flat sequence (in my opinion).
You are using excessive property nodes, you can simply wire them straight through. Because they get calculated in this Subvi.
To your problem, just add some numeric controls who you can replace for the numeric constants.
Then simply select these controls in the terminal (change the patern if you haven't enough space)
Koen
11-06-2013 03:07 AM
Removing the loops and changing the constants to variables it will look more like this:
Hope this will help you with removing the excessive loops/property nodes. I just replaced all constants with controls.
Koen
11-06-2013 03:21 AM
Hi there Koen,
thank you very much for your reply.
I don't know if you ever use the Nonlinear fit VI, but the problem here is that the connection pattern of the reference subVI for the fit must be not changed. That is the problem that I am dealing with.
Anyway thank you a lot.
Cheers,
Nikola
11-06-2013 03:34 AM
Hello Nikola,
No I haven't use that one before.
Checked the vi itself and found the reference in my program files.
When i check the vi most of it is unwired, don't know if that's a problem by me?
Anyway aren't you able to use the cluster control?
Just cluster the elements by name in your main via and unbundle them in this subvi.
Hope this works!
Koen
11-06-2013 03:44 AM
If you just check the output control cluster with the context help you can see that is already defined, and contains two boolean variables, model function and gradient. Both are required and called by reference by the Nonlinear Curve fit VI. So, I am limited there as well.
11-06-2013 04:05 AM
Hmm, aren't you able to just add the extra and unbundle them in the vi.
Because it's obviously a control for the non linear fit not an indicator.
If it does need the control this way I don't know a solution and someone else has to answer it.
11-06-2013 04:10 AM - edited 11-06-2013 04:11 AM
To provide random extra data to the model VI, you need to use the "data" input (it is a variant and thus can contain anything you want!). Simply create any datatype you like (typically a cluster if there are several values of different datatypes) containing all needed values, convert them to a variant in the main VI and wire the variant to the fitting tool. Inside the model, you convert the variant back to data, using a cluster constant as defined in the main VI as "type" (simply right-click the cluster wire in the main VI...create constant...move the constant to the model VI). Now unbundle the various values and use them anywhere inside your model.
11-06-2013 04:16 AM
I did the same yesterday but I send the data to the Call by Reference VI and it was giving me some data type error. Now I just wired the variant data directly to the Nonlinear fit VI and worked perfectly. I hope I am not ruining the fitting procedure, but I saw many replies by you altenbach on this topic, so I think I can trust your experience 🙂
Thank you very much guys for your help, I appreciate it alot!!!
Cheers,
Nikola
11-06-2013 04:18 AM
The data varian is not use anywhere in the system VI (because the contents are only defined by you!). It is simply forwarded unchanged to the model call.