MATLAB: Do I receive “Out of resources” or other error messages when displaying a Scope in Simulink 6.2 (R14SP2)

simulink

I have a model with about 60 scope blocks. I have a couple of them open to display their signals. When running my simulation I receive one of the following error messages:
Warning: Failed in SetDIBits, device does not support this operation (gle00000008)
Out of Window Resources: Allocation of bitmap failed. Disabling backingstore for current figure.
Warning: Unable to create graphics buffer. Your system may be out of memory! The scope display may exhibit problems, but the simulation will continue.

Best Answer

This is an issue with the Zbuffer renderer used in Simulink Scopes. Since this renderer calculates how to display an object on a per pixel basis, expanding many scopes can cause this problem.
To work around this issue, use the following code to utilize the Painters renderer instead of the default Zbuffer renderer for any open Simulink scope.
%Find all open Simulink scopes and return
%their handles to an array called hScopeFig.
hScopeFig = findall(0,'Type','Figure','Tag','SIMULINK_SIMSCOPE_FIGURE');
%Set the renderer for all open scopes to painters.
set(hScopeFig,'Render','painters');
%Turn off the Scople/Zbuffer warnings.
warning('off','Simulink:SL_ScopeRendererNotZBuffer');
Note that this script will only change the renderer for scopes that are open when the script is run. Any subsequently opened scopes, or scopes that are closed are reopened, will return to the zbuffer renderer.
If you include this code in the model start or init function callbacks anytime the model was run all open scopes will be set to painters.