It is very disappointing to see these forums reduced to such low traffic, and so little usability. If it's come so that any question takes weeks to get an answer, presumably because all the kind souls who used to help on here, have now migrated from Matlab to Python/JS/R, then perhaps that's what disappointed Matlab users are best advised to do as well.
Version mismatch with exportgraphics? "class matlab.graphics.internal.mlprintjob has no Constant property or Static method named 'containsUIElements'"
13 views (last 30 days)
Show older comments
When running
fig = figure;
% plotting commands..
exportgraphics(fig, 'd:\plot.emf');
I get the error
Error using exportgraphics
The class matlab.graphics.internal.mlprintjob has no Constant property or Static method named 'containsUIElements'.
I used the same exportgraphics command above for a long time, without problems. What recently happened is that I copied the exportgraphics.m file from c:\Program Files\MATLAB\R2022a\toolbox\matlab\graphics\printing\en\ to c:\Program Files\MATLAB\R2019b\toolbox\matlab\graphics\printing\, in the hopes of being able to use it in Matlab 2019b too. That didn;t work, and when I exited Matlab 2019b and deleted the .m file from its folder, then entered Matlab 2022a, the above error happens.
There's probably been a confusion of file versions, although there seems to now only ever be the 2022a version left:
>> which -all exportgraphics
C:\Program Files\MATLAB\R2022a\toolbox\matlab\graphics\printing\exportgraphics.p
Running restoredefaultpath and savepath doesn't help. I also renamed either the m or the p file to something else, one at a time, to prevent confusion between the two - this too didn't help. What else can I try?
A second question would be: *is there* a way to make `exportgraphics` work in Matlab 2019b, if (clearly) the method of just copying the file over from v2022a does not work?
Answers (1)
Abhishek Kumar Singh
on 28 Dec 2023
Hello,
The function `exportgraphics` was first introduced in MATLAB version R2020a, which means it does not exist in MATLAB R2019b by default. Attempting to copy the function file from a newer version to an older one like R2019b will not work because `exportgraphics` relies on additional functions and system changes that are only present in the newer MATLAB releases.
To address the error you're experiencing in MATLAB R2022a, the recommended course of action is to perform a clean installation of MATLAB. This will ensure that all system files are correct and free from corruption.
Regarding the possibility of using `exportgraphics` in MATLAB R2019b, there is no direct method to transfer a function from a newer version of MATLAB to an older one, especially when the function depends on other features that were introduced in the newer versions. Your options include either using the functions that are already available in MATLAB R2019b or upgrading to a more recent version of MATLAB.
For similar functionality in R2019b, you might consider using alternative functions like `saveas`. Alternatively, you could create a custom function named `exportgraphics` that replicates the desired behavior by utilizing existing functions like `saveas`. You can refer to the documentation at: https://www.mathworks.com/help/releases/R2019b/matlab/ref/saveas.html?s_tid=doc_ta
While it is generally not advised, if you have no alternative, you could try manually copying the `exportgraphics` function file to a directory included in your MATLAB path. Then, you would need to copy its dependencies one at a time, addressing any errors that arise by adding the necessary files. If you encounter an error related to an existing file, you could try replacing it with the corresponding file from the newer MATLAB version.
I hope this information is helpful!
Thanks!
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!