"Mohsen Rajaei" <mrajaei87@gmail.com> wrote in message
news:l2rpsf$lrd$1@newscl01ah.mathworks.com...
> Dear all,
>
> I have a 2by2 matrix and want to get the determinant. This is easy when
> the elements are numbers. For example, when we have
> A=[1 2 ; 3 4]
> det(A) returns 2.
>
> But if I have a matrix of functions, for example
> A=@(x) [x x+1 ; x+2 x],
> I expect that det(A) returns a function which is 3*x2; however, MATLAB
> cannot evaluate this and returns this error:
>
> Undefined function 'det' for input arguments of type 'function_handle'.
>
> How can I find the determinant of this matrix? Is there another way to
> solve this problem??
If you have Symbolic Math Toolbox:
syms x
A = [x, x+1; x+2, x]
det(A)
If you're doing this to try to determine the eigenvalues of the matrix, use
the EIG function instead. Also note that if your A matrix is large and/or
complicated, the expression you'll receive may be quite large and
complicated as well.

Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
