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.
Return the body of a symbolic function by using formula. You can use the body for operations such as indexing into the function. Return the arguments of a symbolic function by using argnames.
Index into the symbolic function [x^2, y^4]. Since a symbolic function is a scalar, you cannot directly index into the function. Instead, index into the body of the function.
Create 2-by-1 and 2-by-2 symbolic matrix variables to represent the matrices and .
syms X[2 1]matrix
syms A[2 2]matrix
Create two symbolic matrix functions to represent the functions and . When creating the symbolic matrix functions, keep existing definitions of the symbolic matrix variables and in the workspace. The symbolic matrix functions require matrices of the same sizes as and as their input arguments.
Define the function and find its derivative . The resulting symbolic matrix functions are in matrix notation in terms of and .
F(X,A) = X.'*A*X
F(X, A) =
dF(X,A) = diff(F,X.')
dF(X, A) =
Convert the symbolic matrix functions from data type symfunmatrix to symfun. The resulting symbolic functions are in scalar notation in terms of the matrix elements of and . These functions accept scalars as their input arguments.
formula — Function body symbolic expression | vector of symbolic expressions | matrix of symbolic expressions
Function body, specified as a symbolic expression, vector of symbolic expressions, or matrix
of symbolic expressions that can be converted to the sym
data type.
Example: x + y
inputs — Input argument or arguments of function symbolic variable | array of symbolic variables
Input argument or arguments of a function, specified as a symbolic variable or array of
symbolic variables, respectively.
Example: [x,y]
Data Types: sym
fM — Symbolic matrix function to convert symbolic matrix function
Since R2024b
Symbolic matrix function to convert, specified as a symbolic matrix
function.
Alternatively, you can use symfunmatrix2symfun to convert a symbolic matrix function to
a symbolic function.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.