Screen Updates
MATLAB Graphics System
MATLAB® graphics is implemented using multiple threads of execution. The following diagram illustrates how the main and renderer threads interact during the update process. The MATLAB side contains the graphics model, which describes the geometry rendered by the graphics hardware. The renderer side has a copy of the geometry in its own memory system. The graphics hardware can render the screen without blocking MATLAB execution.
When the graphics model changes, these updates must be passed to the graphics hardware. Sending updates can be a bottleneck because the graphics hardware does not support all MATLAB data types. The update process must convert the data into the correct form.
When geometry is in the graphics hardware memory, you can realize performance advantages by using this data and minimizing the data sent in an update.
Managing Updates
Updates involve these steps:
Collecting changes that require an update to the screen, such as property changes and objects added.
Updating dependencies within the graphics model.
Sending these updates to the renderer.
Waiting for the renderer to accept these updates before returning execution to MATLAB.
You initiate an update by calling the drawnow
function. drawnow
completes
execution when the renderer accepts the updates, which can happen
before the renderer completes updating the screen.
Explicit Updates
During function execution, adding graphics objects to a figure or changing properties of existing objects does not necessarily cause an immediate update of the screen. The update process occurs when there are changes to graphics that need to be updated, and the code:
Calls
drawnow
,pause
,figure
, or other functions that effectively cause an update (seedrawnow
).Queries a property whose value depends on other properties (see Automatically Calculated Properties).
Completes execution and returns control to the MATLAB prompt or debugger.