Catch error and rethrow as warning in MATLAB

Alec Jacobson

October 05, 2012

weblog/

Here's a matlab try/catch block that catches an error and rethrows it as a warning:
try                                                                                                       
 T=[];                                                                                                    
 T(1);                                                                                                    
catch err                                                                                                 
  warning(err.identifier,err.message);                                                                    
end