LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

mathscript root finding problem

Hi,

i'm having a go at using mathscript but i seem to have hit a problem, i'm having trouble figuring out how to get a root finding system going.

say something simple like find the value that cos(x) = 0 around 3, so acording to an example i saw you would put:

 

x=fzero(@cos,3)


but this returns an error saying '@' is unrecognised.

 

simularly if you wished to look for this value say between 1 and 5 you would put in:

 

x=fzero(@cos, [1,5])

 

am i getting mixed up with Matlab syntax or am i doing it completly wrong??

 

HELP!!

0 Kudos
Message 1 of 5
(7,029 Views)

Hi,

 

MathScript can not recognize symbol @.

The syntax of fzero is

y = fzero(fun, y0); 

where fun is a sting input specifying the name of the function and y0 is a scalar specifying the initial guess for the zero. Therefore, you should use the following script to find zero of cos near 3.

x = fzero('cos', 3)

You can just type 'help fzero' in MathScript Windows to get detail help and example of this functioin.

0 Kudos
Message 2 of 5
(7,022 Views)

Hi, i'm still being dim.

i've attatched a vi that i think i've done what you said.

its lv 8.2.

any help apreciated.

John P.

0 Kudos
Message 3 of 5
(7,016 Views)
Hello John,

Unfortunately, the MathScript fzero function was not available in LabVIEW 8.2.  It was introduced in LabVIEW 8.5.  MathScript in LabVIEW 8.2 also had fairly limited error checking functionality.  Your output variable k2 is also undefined.  Do you have a later version of LabVIEW to try?

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 4 of 5
(7,014 Views)

dang... that would explain it.

 

i guess a code could be wrote to do it.

0 Kudos
Message 5 of 5
(7,009 Views)