%% Refresh Plotted Data
% Refresh charted data to reflect changes in workspace variables.
% First, plot some data and return a Line object.

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

%
% Identify the data sources for the chart by setting the XDataSource and YDataSource properties of the Line object. Then, modify y. Update the chart by calling refreshdata.

ln.XDataSource = 'x';
ln.YDataSource = 'y';
y = sin(3.*x);

refreshdata

% Copyright 2019 The MathWorks, Inc.