exception handling in matlab - try catch -- MatLab

 exception handling in matlab - try catch -- MatLab


When exception occurs, how to handle it?
using exception handling keyword try , catch

syntax:

try
    <statement1>
catch <exceptionName>
    <exception handling statement1>
end


[NOTE]

Great importance. Please pay a lot of attention on it.


(1)
Unlike C language, there can exist 1 catch block for each 1 exception handling in matlab.
(2)
Like C language, there can exist nested try , catch , end.
(3)
UnLike C language, in matlab, if you wanna do different thing according to different exception. You can only determine that in catch block with conditional statement (such as if , switch).

more details on:

Comments

Popular posts from this blog

diagonal matrix--diag

a convenient type to record lots of value in MatLab -- cell matrix

Anonymous Function in MatLab