
550 Accelerating MATLAB
®
Performance
delete(get(hAxes,'Children')); % delete old plot lines
plot(hAxes,xdata,ydata); % display new lines
10.2.2 Plot and Image Update
It is much faster to update an existing graphic object’s properties than to replace it with a
new object. Plot elements (lines, markers, patches, etc.) are a specic example for this gen-
eral advice. For example, instead of replotting the data, it is faster to update an existing plot
line’s data property values (XData, YData, and ZData):
% Prepare the original data
t = 0 : 0.001 : 10; % 10,001 data points
originalYData = sin(t);
% Plot the data
hLine = plot(t,originalYData); ...