LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to solve for polynomial roots using MathScript

Solved!
Go to solution

I understand examples to use the roots.vi to solve 0=Ax^2+Bx+C for the polynomial roots when the coeficients are known...

 

But how do I find the polynomial roots for 0=Ax^y+Bx+C where y=.625 for example?  Ideally I would like to do this in matscript which I am already using.

 

Hopefully this is a trivial question but I am over my head!

 

Thanks in advance!

0 Kudos
Message 1 of 16
(4,646 Views)

Your second equation is not a polynomial, but at any rate I would investigate the fzero MathScript Function to find the zeros.

 

http://zone.ni.com/reference/en-XX/help/371361E-01/lvtextmath/msfunc_fzero/

 

0 Kudos
Message 2 of 16
(4,635 Views)

Can someone give me an example of how to use fzero to solve for the roots of 0 = Ax^.625 + Bx + C?  Or any other MathScript method.  As I have said, this is new to me and example code is rare!

 

Thanks again.

0 Kudos
Message 3 of 16
(4,613 Views)
0 Kudos
Message 4 of 16
(4,609 Views)

Giving me the same answer again that I was responding to is of no help.  I have read the referenced page several times and tried to code it for my equation but am getting nowhere.  Is posting a working example VI using this function to solve my specific equation possible?

 

Thanks

0 Kudos
Message 5 of 16
(4,602 Views)

Oh, sorry.  I didn't see that Darin had posted that link....

 

Follow the instructions on that link and you get a working example...

 

 

 

Save the following script as nonlinzero.m in a directory in the MathScript search path:

Message Edited by elset191 on 11-25-2009 09:18 AM
--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 16
(4,599 Views)
In front of me I only have Mathscript running on LV8.2, and I believe fzero is an 8.5 addition .  If you diligently followed the directions in the help page, perhaps that is your problem.  Try wiring an indicator to the error out connection and see what it tells you.  Otherwise, post your attempt and we'll try to fix it.
0 Kudos
Message 7 of 16
(4,584 Views)

Tim - Thanks for the help.  My test vi is exactly as your posted example.  The rub is the script - which you did not post?

 

In any event I am not sure this is going to be a workable solution as my polynomial coefficients are calculated and change constantly.  I can not hard code them in a script.  Does that make sense?

0 Kudos
Message 8 of 16
(4,578 Views)

The script is 4 lines.  And I copied and pasted it directly from that help page.  Make sure you save it where it tells you to (default is My Documents\Labview Data).  Or save it at a custom directory, but make sure you tell labview to look there.

 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 9 of 16
(4,573 Views)
Tim - maybe I just have no clue - but how does that four lines solve my equation?  I need an example of how to use fzero to solve for the roots of 0 = Ax^.625 + Bx + C specifically and the coefficients will be constantly changing....  David
0 Kudos
Message 10 of 16
(4,563 Views)