04-13-2009 05:38 PM
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!
Solved! Go to Solution.
04-14-2009 12:01 AM
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.
04-14-2009 07:40 AM
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."
04-14-2009 09:16 AM
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
04-14-2009 10:28 AM