MATLAB: Do I receive an error when I run the MATLAB file generated using PRINT with ‘-dmfile’ option for a figure in MATLAB 7.0 (R14)

dmfilefigureguiMATLABmfileplotprintsaveas

I save a figure as a MATLAB file using PRINT '-dmfile' as follows:
plot(1:20)
print -dmfile Fig.m
When I try to run that generated MATLAB file, I get the following errror:
??? Invalid line property: 'DisplayName'.
Error in ==> Fig at 46
h3 = graph2d.lineseries(...

Best Answer

Usage of the '–dmfile' option to PRINT has been deprecated and is restricted to GUIDE only. In order to generate MATLAB code for a figure containing plots, use SAVEAS with MATLAB file option.
Execute the following at the MATLAB command prompt:
h = figure;
plot(1:20);
saveas(h,'Figure1','m');
This will generate 'Figure1.m' as required. For more information on SAVEAS function, execute the following at MATLAB command prompt:
web([docroot '/techdoc/ref/saveas.html'])