MATLAB: Communicate an error with the APP

app designererrorMATLAB

I have created an app in app designer. It works well, but the only problem is stopping the app when an error occur. I have to run a function file from the app, so when there is an error in that function file, the information should be communicated with the app, so that the app can be stopped. Is there any way to do it.
Thank you.

Best Answer

  • try
    catch ME
    function Functionfilecalling
    %example of something that generates an error
    [status, attr] = fileattrib(pwd);
    if ~status || attrib.UserWrite ~= 1
    error('You cannot write to the current directory');
    %no error, do something
    fprintf('The rain in Spain is mainly in the plains.\n')