MATLAB: Optimization in the presence of symbolic parameters

MATLABoptimizationOptimization ToolboxsymbolicSymbolic Math Toolbox

Hello,
I have an optimization problem, let's say finding the minimum of fun(x) where x is a real scalar, where for example: fun(x) = A*tanh(x) – x^2; The function fun has a parameter A which I'd like to specify as a symbolic variable such that the solution x is given as a function of A. The brute force solution will be to go over different valid values of A and finding x per each such value of A. Is there a way for Matlab to output x as a function of A instead?

Best Answer

Something like
syms A x
f(x)=A*tanh(x)-x^2;
solve(diff(f)==0,x);
?
Best wishes
Torsten.