0

When I create a 3 by 3 identity matrix and try to find the determinant of it, here's what I get: K = eye(3)

K =

   1              0              0       
   0              1              0       
   0              0              1       

det(K) Subscript indices must either be real positive integers or logicals.

What does this error mean, and how can I fix this?

Bri W.
  • 1
  • 6
    you probably assigned `det` to a variable at some point. `clear det` and try again. – pragmatist1 Oct 12 '15 at 01:24
  • Also I hope you have a good reason to be calculating the determinant of an identity matrix using Matlab... – David Oct 12 '15 at 04:10
  • There's absolutely no reason to call `det` on the identity matrix when it's simply 1. That's a known property: https://en.wikipedia.org/wiki/Identity_matrix - *"... It follows that the determinant of the identity matrix is 1 and the trace is `n`."*. Here `n` refers to the number of rows/columns of the matrix. Nevertheless, see the duplicate question for more details. As noted by @pragmatist1, you probably declared a variable called `det` and you are overshadowing the function with the variable name. – rayryeng Oct 12 '15 at 05:01

0 Answers0