LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

fminsearch error message

Solved!
Go to solution

When I try to use fminsearch, I get the error message "LabVIEW:  The given name does not correspond to a know function, variable, or symbol." 

 

For example, I define a function "testfn" by making an m-file called "testfn.m" containing

 

funtion z=testfn(x,y)

z=x.^2+y.^2;

return

 

and I store it in the current directory, and I make sure that this directory is part of the path. Furthermore, when I try it out, like so

 

testfn(1,2)

 

the function does execute, and I get the proper value back.  But when I type

 

X=fminsearch('testfn',[1,1])

 

I get the error message.

 

On the other hand, if I type

 

x=fminsearch('sin',[1])

 

I get back x= -1.5708, so fminsearch itself seems to be working for me, and I feel like I understand the syntax.  I just don't know how to tell it where to look for my function.

 

Thanks for any help! 

0 Kudos
Message 1 of 5
(6,865 Views)

Hi,

 

"The function you specify must accept a vector of the same length as xstart and return a scalar."

 

See detail in help of fminsearch.

0 Kudos
Message 2 of 5
(6,864 Views)

OK, so I think you're telling me that I have to change the .^ operators with ^, so that the function would be unable to accept 1-D arrays.  Is that right?

 

I change the test function to

 

function z=testfn(x,y)

z=x^2+y^2

return

 

and now I get a different error. "A problem occurred in a subVI call."

0 Kudos
Message 3 of 5
(6,854 Views)
Solution
Accepted by topic author mbira

Hi,

 

Your function should not accept more than one inputs. And, the only input should be a vector.

 

http://forums.ni.com/ni/board/message?board.id=MathScript&thread.id=361

0 Kudos
Message 4 of 5
(6,850 Views)
OK.  Thanks!  That means that the mathscript fminsearch is very restricted compared to the matlab version, and I'll probably have to try a different approach.
0 Kudos
Message 5 of 5
(6,845 Views)