Plot objects let you link a with properties that contain data. For example, the object has data source properties associated with the XData, YData, and ZData properties. These properties are called , YDataSource, and .

To use a data source property:

  • Assign the name of a variable to the data source property that you want linked to an expression.
  • Calculate a new value for the variable.
  • Call refreshdata to update the plot object data.

refreshdata lets you specify whether to use a variable in the base or the of the from which you call refreshdata.

Data Source Example

The following example illustrates how to use this technique:

Changing the of Data

function datasource_ex
t = 0:pi/20:2*pi;
y = exp(sin(t));
h = plot(t,y,'YDataSource','y');
for k = 1:.1:10
	y = exp(sin(t.*k));
	refreshdata(h,'caller') % Evaluate y in the function workspace
	drawnow; pause(.1)
end

If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the until you have changed all data source properties to appropriate values.