MATLAB: Do I get an error in ‘uiopen’ every time I try to open a file in MATLAB

editeditorerrorfileimformatsMATLABopenshadowsum.muiopen

I am unable to open any files in MATLAB. When I double-click on a file, or select it from the 'Open' GUI, I get lots of error messages:
Error: File: sum.m Line: 8 Column: 1
Illegal use of reserved keyword "end".
Error in imformats>find_in_registry (line 519)
switch (sum(match))
Error in imformats (line 121)
varargout{1} = find_in_registry(fmts, varargin{1});
Error in imread>parse_inputs (line 514)
fmt_s = imformats(varargin{2});
Error in imread (line 340)
[source, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt,
varargin{:});
Error in matlab.ui.internal.dialog.DialogUtils.imreadDefaultIcon (line 39)
[iconData, ~, alphaData] = imread(iconFileName, 'BackgroundColor',
'none');
Error in msgbox>setupStandardIcon (line 446)
[iconData, alphaData] =
matlab.ui.internal.dialog.DialogUtils.imreadDefaultIcon(iconName);
Error in msgbox (line 361)
Img = setupStandardIcon(IconAxes, IconString);
Error in errordlg (line 59)
handle = msgbox(ErrorStringCell,dlgName,'error',replace);
Error in uiopen (line 202)
errordlg(err);

Best Answer

It is likely that you are getting this error because a builtin MATLAB function is being shadowed by another function or script.
To figure out which function might be shadowed, refer to the first line of the error message. In this case, there appears to be an issue with the file "sum.m". You can view all of the functions by this name with the following command:
>> which -all sum
If the first line of your error message points to a different function, execute the following command, where <functionname> is substituted with the name:
>> which -all <functionname>
Examine the output for any results that are not builtin MATLAB functions, such as "C:\Documents\sum.m". You then have a couple options:
1. Rename the file which is shadowing the builtin function.
It is suggested that you do not use the same name as a MATLAB builtin for any custom functions or variables, to avoid a name conflict.
2. Remove this file from your path.
If you are not able to rename this file, then you can remove it from your MATLAB path so the builtin function will run instead of this custom function or script.
After following one of these steps, try again to open a file. It is possible that you will get the following error:
Previously accessible file <the file you removed> is now inaccessible.
If this is the case, restart MATLAB, and then you should be able to open files again.