Matlab is a deterministic language. When this line of code is reached, the condition is checked reliably. And if the condition is true, you can be sure, that the error appears. So there are several possible causes for your observations:
- You do not call the function you edit. E.g. there could be another function with the same name in another folder of Matlab's path.
- It is the right function, but you did not save it after some changes. Then you do not run the version you see in the editor.
- In opposite to your expectations, the condition is not TRUE.
- You have redefined the function "error", such that the original function is shadowed. Then error() is called, but Matlab performs something else.
You can check all these ideas easily: Simply set a breakpoint in this line, start Matlab again, and when the line is reached, check the values of x and a(1). Then step forward one line and step into the error function on demand. If the breakpoint is not reached, you call another function.
But in any way you can be sure, that Matlab does exactly what it is instructed to do. There is no magic avoidance of commands or lazy decisions not to step into the if-clause.