MATLAB: Does MATLAB 6.0 (R12) crash if I try to open it after saving a figure using the Camera Toolbar

cameratoolbarcrashfigureloadMATLABopenperspectiveprojection

Why does MATLAB 6.0 (R12) crash if I try to open it after saving a figure using the Camera Toolbar?
I create a figure in MATLAB 6.0 (R12), and perform some operations using the Camera Toolbar (e.g., using "View–>Camera Toolbar").If I save it and try to reopen it, MATLAB crashes.This will even happen if I hide the Camera Toolbar, or avoid actually using it after enabling it.The following code will reproduce the crash:
hf = figure;
peaks;
cameratoolbar show
cameratoolbar hide
hgsave(hf,'corrupt.fig')
close(hf)
openfig corrupt
------------
Assertion detected at Fri Apr 12 11:08:49 2002
------------
Assertion failed: ((table_index >= 0) && (table_index < BASE_TABLE_SIZE)),
at line 859 of file "./mwmem.c".
Cache consistency error: Table index out of range
Configuration:
MATLAB Version: 6.0.0.88 (R12)
Operating System: Microsoft Windows 2000
Window System:Version 5.0 (Build 2195: Service Pack 1)
Processor ID: x86 Family 6 Model 8 Stepping 6, GenuineIntel
Virtual Machine:Java 1.1.8 from Sun Microsystems Inc.
Stack Trace:
[0] matlab.exe:_mnSignalHandler(0xffffffff, 0, 0, 1) + 452 bytes
[1] matlab.exe:_ThrowAssertion(0x1ed15ce4, 0xffffe910, 0x65737341, 0x6f697472) + 167 bytes
[2] matlab.exe:_MATLABAssertFcn(0x015df098 ": ((table_index >= 0) && (table_..", 0x015deaa4
"./mwmem.c", 859, 0x015df0d4 "Cache consistency error: Table i..") + 131 bytes
[3] libut.dll:_ut_assertstr(0x015df098 ": ((table_index >= 0) && (table_..", 0x015deaa4 "./mwmem.c", 859, 0x015df0d4 "Cache consistency error: Table i..") + 25 bytes
[4] libut.dll:_mw_free(0x1ed15cec, 0x77f43673, 0x1ed15cec, 0x014ba26c) + 165 bytes
[5] libut.dll:_utFree(0x1ed15cec, 0x1ed15cec, 0x1ed18b48, 0x014ba284) + 25 bytes
[6] uiw.dll:_UIW_DestroyWSCData(0x1ed18b48, 0x1ed15cec, 0x1ed18b48, 0x1ed15ce0) + 31 bytes
[7] gui.dll:_wm_DestroyWSCData(0x1ed18b48, 0x1ed15cec, 0x1ece80c8, 0x1ed15ce0) + 24 bytes
[snip]

Best Answer

This is a bug in MATLAB 6.0 (R12) that has been fixed in MATLAB 6.1 (R12.1).
If you have created the figure in R12, There are a few things you can do to recover it:
1) Note that the corrupt figure created in R12 will open in R12.1. Therefore, you can upgrade to MATLAB 6.1 (R12.1) by contacting Customer Service at service@mathworks.com, or by calling 508-647-7000.
2) If you have MATLAB 6.1 (R12.1) available, you can open the figure, delete the cameratoolbar, and resave the figure. Then you will be able to open it in MATLAB 6.0 (R12). Note that hiding the toolbar is not the same thing as deleting it. Provided that you have the handle to the figure, or it is the current figure, you can delete the cameratoolbar using the following command:
delete(findall(gcf,'tag','CameraToolBar'))
To avoid this crash in the future, you will need to avoid enabling or using the cameratoolbar. If you need to use the cameratoolbar before saving the figure, you will need to delete it from the figure before saving it. See workaround (2) above for instructions on deleting the toolbar.