Main Content


Convert symbolic matrix function to symbolic function



f = symfunmatrix2symfun(fM) converts a symbolic matrix function fM of type symfunmatrix to a symbolic function f of type symfun.

The output symbolic function has the same matrix dimensions as the input symbolic matrix function, and its components are filled with automatically generated elements. For example, syms fM(x) [1 2] matrix; f = symfunmatrix2symfun(fM) converts the symbolic matrix function fM(x) to the symbolic function f(x) = [fM1_1(x), fM1_2(x)]. The generated elements fM1_1 and fM1_2 do not appear in the MATLAB® workspace.


collapse all

Create 2-by-1 and 2-by-2 symbolic matrix variables to represent the matrices X and A.

syms X [2 1] matrix
syms A [2 2] matrix

Create two symbolic matrix functions to represent the functions F(X,A) and F(X,A)/XT. When creating the symbolic matrix functions, keep existing definitions of the symbolic variables X and A in the workspace. The symbolic matrix functions require matrices of the same sizes as X and A as their input arguments.

syms F(X,A) [1 1] matrix keepargs
syms dF(X,A) [2 1] matrix keepargs

Assign the function F(X,A)=XTAX and find its derivative F(X,A)/XT. The results are in matrix notation in terms of X and A.

F(X,A) = X.'*A*X
F(X, A) = XTAX
dF(X,A) = diff(F,X.')
dF(X, A) = AX+ATX

Convert the symbolic matrix functions from data type symfunmatrix to symfun. The results are in scalar notation in terms of the matrix elements of X and A. These functions accept scalars as their input arguments.

Fsymfun = symfunmatrix2symfun(F)
Fsymfun(X1, X2, A1_1, A1_2, A2_1, A2_2) = X1A1,1X1+A1,2X2+X2A2,1X1+A2,2X2
dFsymfun = symfunmatrix2symfun(dF)
dFsymfun(X1, X2, A1_1, A1_2, A2_1, A2_2) = 


Input Arguments

collapse all

Input, specified as a symbolic matrix function.

Data Types: symfunmatrix


  • To show all the functions in Symbolic Math Toolbox™ that accept symbolic matrix functions as input, use the command methods symfunmatrix.

Version History

Introduced in R2022a