MATLAB: Does the FIG-file become corrupted after removing a dataset from the figure in MATLAB 7.0 (R14)

datadeletefiggraphichandlelegendMATLABremovesave

I created a figure that contains more than one dataset and a legend using the following code:
figure
plot(sin(1:.01:2*pi),'-r')
hold on
plot(cos(1:.01:2*pi),'*b')
legend('Sine', 'Cosine')
I saved the figure to a FIG-file, closed it, and then reopened it. I modified the figure using the following steps:
1. Select the "Edit Plot" option from the figure's toolbar
2. Click on one of the datasets to select it
3. Press the "Backspace" button to delete the dataset
4. Resave the figure
When I try to open the modified FIG-file an error dialog appears with the following error:
Error using ==> open
invalid argument

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that the LEGEND function handles data that is removed from a figure.
To work around this issue, recreate the legend appropriately after removing the data set. For the example above, if you removed the cosine wave from the figure, recreate the legend as follows:
legend('Sine')