www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/RefreshGraphExample.m

    %% Refresh Graph with Updated Data
% Plot a sine wave and return the chart line handle, |h|. 
%%

% Copyright 2015 The MathWorks, Inc.

x = linspace(0,8);
y = sin(x);
figure
h = plot(x,y);

%%
% Identify the data sources for the plot by setting the |XDataSource| and
% |YDataSource| properties of the line to |x| and |y|, respectively. 
% Then, modify |y|. Call |refreshdata| so that the graph updates with the
% changes to |y|.

h.XDataSource = 'x';
h.YDataSource = 'y';

y = sin(x.^3);
refreshdata