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.
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
Input argument or arguments of a function, specified as a symbolic variable or array of
symbolic variables, respectively.
Example: [x,y]
Data Types: sym
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.