Fixed self-assigment bug that made matlab crash