NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
mbira
Posts: 3
0 Kudos
Accepted Solution

fminsearch error message

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! 

Active Participant
ttrr
Posts: 225
0 Kudos

回复: fminsearch error message

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.

Member
mbira
Posts: 3
0 Kudos

Re: fminsearch error message

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."

Active Participant
ttrr
Posts: 225
0 Kudos

回复: Re: fminsearch error message

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

Member
mbira
Posts: 3
0 Kudos

Re: 回复: Re: fminsearch error message

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.
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page