Unexpected comma in array expression Stacktrace:

In the portion of the code [1 -exp(..., if you have a space to the left of - but not to the right of it, then it is parsed as a unary operator and the structure is parsed as a matrix instead of just a vector. Commas are not allowed in matrix expressions.

To achieve the desired result, either:

  1. Delete the space, [1-exp(..., or
  2. Ensure there are spaces on both sides, [1 - exp(....

It is good practice to make the whitespace around operators symmetric for readability anyway.