I define a function called f[x], which gives a numerical result interacting with an external free software called FEMM, using NETLink.
This function works properly and the following codes give the expected result:
Plot[f[x],{x,0,30},MaxRecursion->0,PlotPoints->30]
I try to do some optimization using this function. In order to do that I use
NMinimize[f[x],x,Method->"RandomSearch"]
But an error appears as below:
"error: attempt to perform arithmetic on global `x' (a nil value)".
What could be the cause of this problem?
Thanks for your help!
f
, but try definingff[x_?NumericQ]:=f[x]
and optimizingff
instead. $\endgroup$