Undefined variable "matlab" or class when opening MATLAB figure

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

4 Kommentare

Matt J
Matt J am 5 Sep. 2018
Bearbeitet: Matt J am 5 Sep. 2018
What happens when you do
>>which matlab.graphics.internal.convertStringToCharArgs
You should get something like
C:\Program Files\MATLAB\R2018a\toolbox\matlab\specgraph\+matlab\+graphics\+internal\convertStringToCharArgs.m
Hi Matt,
I get:
>> which matlab.graphics.internal.convertStringToCharArgs
'matlab.graphics.internal.convertStringToCharArgs' not found.
That would appear to answer the "why". Is there a neat way to get back this file? The contents of my +internal directory are:
Louis
Matt J
Matt J am 5 Sep. 2018
Bearbeitet: Matt J am 5 Sep. 2018
Did you do a completely clean re-install (i.e, completely delete the corrupted R2014a install folder)? If not, I would try that. If yes, it might be time to turn to tech support.
Hi Matt,
I just reinstalled into the same directory per the advice from MATLAB Support on a previous post. I will try again with a totally clean install and contact support directly if necessary. Thanks for your help!
Louis

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt J
Matt J am 5 Sep. 2018
Bearbeitet: Matt J am 5 Sep. 2018

1 Stimme

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?

4 Kommentare

Matt, I think you might have nailed it. In fact, I have separate licenses: A standard license for R2014a at work and a personal license for R2018a at home. Once I have completed my totally clean install of 2014a I will have another look.
Thanks,
Louis
@Matt, I'm fairly certain you're not allowed to post copyrighted files on this forum.
Hi Matt,
A totally clean reinstall fixed the issue. I definitely copied over some code from 2018a by mistake, causing the missing class error. Thanks again for all your help!
Louis
@Guillame: I have edited out the copyrighted material.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Guillaume
Guillaume am 5 Sep. 2018
It doesn't look like your openfig.m is the R2014a version. Strings were introduced in R2016b and in my version (R2018a), convertStringToCharArgs.m has a start copyright of 2017 so it's unlikely that it would have existed in R2014a. Older functions usually have a copyright of the form creationyear-lastmodificationyear, e.g. for openfig in R2018a: Copyright 1984-2017.
Do you have an openfig.m in your user directory that would take precedence over the built-in one? What does
which openfig -all
return?
In addition, be aware that the graphics engine was radically changed in R2014b so it's possible that figure saved with versions > R2014a cannot be opened in R2014a.

1 Kommentar

Hi Guillaume,
You are correct. A clean reinstall fixes the problem.
Louis

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2014a

Gefragt:

am 5 Sep. 2018

Bearbeitet:

am 5 Sep. 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by