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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.