LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

solving nonlinear equation with VI

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 

0 Kudos
Message 1 of 10
(3,850 Views)

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

0 Kudos
Message 2 of 10
(3,814 Views)

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

0 Kudos
Message 3 of 10
(3,800 Views)

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

0 Kudos
Message 4 of 10
(3,793 Views)

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

 

0 Kudos
Message 5 of 10
(3,781 Views)

AhSmiley Happy I think I figured out. I should use "Substitute Variables VI ". Seems it works for me.

0 Kudos
Message 6 of 10
(3,777 Views)

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

0 Kudos
Message 7 of 10
(3,765 Views)

Thank you Lynn.

Can I have your VI please?

0 Kudos
Message 8 of 10
(3,752 Views)

What version of LV are you using?

 

Lynn

0 Kudos
Message 9 of 10
(3,720 Views)

2012

0 Kudos
Message 10 of 10
(3,718 Views)