MATLAB: Error dialog instead of error message in command window

errordlgMATLAB

Hi! Is it possible to get a error dlg instead of error msg i command window? Tanks Johan

Best Answer

Try this:
try
% Some code that generates an error/exception.
catch ME
errorMessage = sprintf('Error in function blah_blah_blah().\n\nError Message:\n%s', ME.message);
% Print to command window.
fprintf(1, '%s\n', errorMessage);
% Display pop up message and wait for user to click OK
uiwait(warndlg(errorMessage));
end