symfun Create symbolic functions collapse all in page Syntax f (inputs) = formula f = symfun (formula,inputs) Description example f (inputs) = formula creates the symbolic function f. For example, f (x,y) = x + y. The symbolic variables in inputs are the input arguments. The symbolic expression formula is the body of the function f.
The syms function creates a symbolic object that is automatically assigned to a MATLAB® variable with the same name. The sym function refers to a symbolic object that can be assigned to a MATLAB variable with the same name or a different name. Assign Symbolic Variables to MATLAB Variables The syms function creates a variable dynamically.
syms lists the names of all symbolic scalar variables, functions, and arrays in the MATLAB workspace. example S = syms returns a cell array of the names of all symbolic scalar variables, functions, and arrays. Examples collapse all Create Symbolic Scalar Variables Create symbolic scalar variables x and y. syms x y x x = y y =
When you convert a symbolic matrix to a MATLAB function, matlabFunction represents it by a dense matrix by default. If most of the elements of the input symbolic matrix are zeros, the more efficient approach is to represent it by a sparse matrix. Create a 3-by-3 symbolic diagonal matrix. syms x A = diag (x*ones (1,3))
You can use matlabFunction to generate a MATLAB® function handle that calculates numerical values as if you were substituting numbers for variables in a ...
Adam's answer https://www.mathworks.com/matlabcentral/answers/449489-converting-anonymous-function-to-a-symbolic-function#answer_364896 works fine for me on ...