MATLAB: Am I able to save a figure to a filename with parentheses “()” in it but am unable to open this figure

figurefilenameMATLABnameopenparenthesesparenthesissave

MATLAB lets me save figures to filenames with parentheses in them, whether I use HGSAVE, SAVEAS, or the "File–>Save…" menu. However, if I try to open the file:
hf = figure;
plot(rand(5))
hgsave('test().fig')
hgsave('test()2.fig')
close(hf)
open('test().fig')
I receive errors:
??? Error: ";" expected, "." found.
Error in ==> D:\Applications\MATLAB6p5\toolbox\matlab\general\open.m
On line 66 ==> fullpath = which(name);
Opening the 'test()2.fig' file gives a slightly different error:
open('test()2.fig')
??? Error: ";" expected, "identifier" found.
Error in ==> D:\Applications\MATLAB6p5\toolbox\matlab\general\open.m
On line 66 ==> fullpath = which(name);
I get the same errors if I open them using the "File–>Open…" menu.
I don't expect this problem. The MATLAB documentation states that I should be able to use non-alphanumeric characters if my operating system supports them. Type the following MATLAB command to see this documentation:
web([docroot '/techdoc/matlab_prog/ch16_pr3.html#60268'])

Best Answer

This bug has been fixed for Release 14 SP1 (R14SP1). For previous releases, please read below for any possible workarounds:
This bug has been reported to our development staff to be investigated for a future release of MATLAB. If you save a figure to filename with parentheses, you will not be able to open it using the OPEN command or the "File-->Open..." menu.
To work around this problem, you can open the figure using the OPENFIG command. For example:
hf = figure;
plot(rand(5))
hgsave('test()3.fig')
close(hf)
openfig('test()3.fig')
Another way to work around the problem is to rename the file, excluding the parentheses.