Jeremy
Jeremy

Reputation: 399

return statement after throw error in matlab

For my simple codehere It seems that the return statement is not needed after the error statement.

  1. Does that mean the function would be early terminated once error is thrown?
  2. If the above is true, what if i do want to process with the rest of function even after an error is thrown. For example, i can still compute c = a - b in my function.

Upvotes: 1

Views: 304

Answers (1)

Jens Lindahl
Jens Lindahl

Reputation: 410

  1. Yes, the error terminates the program.
  2. As suggested by Hoki, use a warning instead.

Note: Your function will throw anyway, if only modifying the code to use warning. This is because the return variable c is not assigned before after the if-statement.

Upvotes: 3

Related Questions