MATLAB: Undefined variable “matlab” or class when opening MATLAB figure

convertstringtocharargsMATLABopenfing.m

Dear all,
This question is a follow-on from Restore MATLAB functions e.g. openfig.m.
I had messed around with openfig.m and started getting an error message when trying to open MATLAB .fig files. I followed the community's advice to reinstall MATLAB (play stupid games, win stupid prizes).
However, since reinstalling MATLAB 2014a, I still cannot open MATLAB .fig files and I get the same error message:
Error using open (line 162)
Undefined variable "matlab" or class "matlab.graphics.internal.convertStringToCharArgs".
I have tried restoring the default path:
resotreDefaultPath
I have refreshed the function and file system caches and clearing classes:
rehash
clear classes
I also double-checked C:\Program Files\MATLAB\R2014a\toolbox\matlab\graphics and found that the folder has definitely been restored to its factory state since reinstalling MATLAB.
I ran to line 162 of open.m:
feval(openAction,fullpath)
The exception occurs on line 97 of openfig.m:
args = matlab.graphics.internal.convertStringToCharArgs(args);
For some reason, matlab.graphics.internal.convertStringToCharArgs is no longer found.
Does anyone have a clue how I can get MATLAB to once again recognise this class?
Best regards,
Louis

Best Answer

So, looking at the code for convertStringToCharArgs, I see that it calls methods, in particular isstring(), that were not available until R2016b when string variables were first introduced. Since you are working in R2014a, it is unclear why it would be looking for that function. My best guess is that you created the .fig file in a more recent version of Matlab at which time you put string variables into its UserData. Now you are trying to read that back into R2014a and it does not have functions needed to handle the string variable type.
What happens when you create a new .fig file in your newly re-installed R2014a? Can openfig process that file?