06-08-2014 01:22 AM
Hi,
I want to use LabView to solve a nonlinear equation. I read forums and figured out that I can use Nonlinear System Solver. vi and I noticed there are two options to write the equation: 1) F(X) is formula and 2) F(X) is VI. I could use the first option and write the equation with that but I did not understand how to use a sub-Vi to provide the equation. Would any one please tell me how to do that?
Thank you
06-08-2014 01:58 PM
Soran,
Read the detailed help for the solver VI.
The VI usually executes much faster than the formula parser/evaluator. Since solvers (and curve fitters, which have the same options) may need to evaluate the function many times while solving, that time can become significant.
In the help is a link to a template for the VI you need. You must use the exact connector pane and reference type. While you can create your own VI, it is much easier to use the template. On the block diagram create the code to generate your equation values in the configuration required by the solver. Be careful to put the parameters in the correcto order.
Lynn
06-08-2014 03:20 PM - edited 06-08-2014 03:21 PM
I see that you have created a second thread. Please keep everything in one place - here. It makes it easier for various people who might try to help or who want to learn from what you did.
What are typical values for a, b, and c? What are the expected solutions for those values?
The program will run for me but I have no easy way to tell how good the solutions are.
Lynn
06-08-2014 03:46 PM
If the range of y includes zero, it might be better to rewrite the first equation as a*x*y + b + c*y = 0 to avoid a possible divide by zero error. Of course to satisfy that equation at y=0, you get b = 0.
Lynn
06-08-2014 05:43 PM
Hi Lynn,
Thank you for your reply.
The equation that I get is not exactly that one I have mentioned above. I mentioned that one just as an example. As you said, lets change the second equation to a*x*y + b + c*y = 0. The point that I would like to know is how I can define such a equation while a, b, and c coefficients are variables not constant. In other words, the user should specify these a, b, and c and the code should give x and y if there are real solutions (if there are no real soltuions, the code shoud give an error).
Thanks again
06-08-2014 05:49 PM
Ah I think I figured out. I should use "Substitute Variables VI ". Seems it works for me.
06-08-2014 07:11 PM
I just passed a, b, and c as an array into the Data input of the Zero Finder f(x) nD.vi. Place an array control on the front panel of the main VI so the users can enter the values.
Lynn
06-08-2014 11:14 PM
Thank you Lynn.
Can I have your VI please?
06-09-2014 12:57 PM
What version of LV are you using?
Lynn
06-09-2014 12:58 PM
2012