Unread post Mon Nov 07, 2016 2:08 am

eye(3) slow - use [1 0 0;0 1 0;0 0 1]

An easy way to speed up your code is to use [1 0 0;0 1 0;0 0 1] instead of eye(3). I got a 30% improvement by just making that change. :D I guess matlab creates the matrix every time it sees eye(3) but when it sees [1 0 0;0 1 0;0 0 1] it is precompiled as a constant. (guessing, no idea if this is true)

-Guru