MATLAB: ‘Not convertible to floating-point’ error when using min() with symbolic variables

errorfloating pointmanminSymbolic Math Toolboxsymfun

I am trying to create a symbolic function that uses sqrt and min and I am getting an error. The code is
xx = sym('xx','real') ;
LambdaCC = symfun(sqrt(1-2*min(xx,1/2)), xx) ;
and the error is that 'xx' is not convertible to floating-point number. Does that mean that it's not possible to use 'min' inside a symbolic function?

Best Answer

The reason of the error is that the input arguments to "min" are not "convertible to floating-point numbers" as "xx" is a symbolic variable. To avoid the error, one could wrap the call to "min" in another symbolic function such that "xx" is conceivably reduced to a floating number. Here is the code that does that:
xx = sym('xx','real') ;
symmin = @(x,y)feval(symengine,'min',x,y);
LambdaCC = symfun(sqrt(1-2*symmin(xx,1/2)), xx);
Also, the link below might be helpful as well: