Declaring an sdpvar object named i or j inside a function fails

Updated:


This is one of the weirdest bugs in MATLAB I have come across. If you define your own class (such as sdpvar) and use the constructor inside of a function body and assign the name i or j to the object, MATLAB fails to perform the definition, and i or j remains to point to the imaginary number. The bug has been reported and been acknowledged by The Mathworks. If you stumble upon this problem (very rare), just change the variable name. On some installations, it seems like this is failing on a more general situation: if your variable is defined command-line style and there exist a function in your path with the same name.

Leave a Comment