MATLAB: How to save to a variable and/or file, an error message from a guide

error messagesave

When I get an error message from a guide, how can I save them to a variable or a file? Thank you Denise

Best Answer

In the code that you think might generate an error, instead of calling
Some Statement Here
encode it in a try/catch block that does whatever you want with the error
try
Some Statement Here
catch ME
%deal with the error the way you need
fprintf('Caught error "%s" with details "%s"\n', ME.identifier, ME.message);
end