refreshdata - Refresh charted data - MATLAB (original) (raw)

Main Content

Syntax

Description

refreshdata updates charted data in the current figure to reflect changes in workspace variables. Before using refreshdata, you must first set the data source properties (for example, XDataSource) of the charts. The function evaluates these data sources before updating the charts.

example

refreshdata([target](#mw%5Fe9bc359b-4136-48ea-b2b9-ac59a363c238)) updates charted data in the specified figure, axes, or chart with data source properties.

example

refreshdata([target](#mw%5Fe9bc359b-4136-48ea-b2b9-ac59a363c238),[workspace](#mw%5Fc3d575cd-a308-49ae-8460-d7a9ec4091b7)) specifies the workspace where the data source properties are evaluated.

Examples

collapse all

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);

Figure contains an axes object. The axes object contains an object of type line.

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

Figure contains an axes object. The axes object contains an object of type line.

Refresh Plotted Data for One Line

Refresh charted data for a specific line and leave other lines unchanged.

First, plot two sets of polar data and return the Line objects.

theta = linspace(0,2*pi); rho1 = sin(theta); rho2 = -sin(theta);

px = polaraxes; hold on; ln1 = polarplot(theta,rho1); ln2 = polarplot(theta,rho2);

Figure contains an axes object with type polaraxes. The polaraxes object contains 2 objects of type line.

Set the RDataSource property for each line. Then, modify rho1 and rho2.

ln1.RDataSource = 'rho1'; ln2.RDataSource = 'rho2';

rho1 = 0.5sin(theta); rho2 = 0.5cos(theta);

Update only the first line by using ln1 as the input argument to refreshdata. Note that the second line remains unchanged.

Figure contains an axes object with type polaraxes. The polaraxes object contains 2 objects of type line.

Input Arguments

collapse all

target — Target object

Figure object | Axes object | PolarAxes object | GeographicAxes object | chart object

Target object, specified as a Figure object,Axes object, PolarAxes object,GeographicAxes object, or chart object with data source properties. For example, Line objects have an XDataSource andYDataSource property.

workspace — Workspace

'base' (default) | 'caller'

Workspace where data source properties are evaluated, specified as one of these values:

If you set data source properties of variables that are not in the base workspace, then you must specify the workspace option as 'caller'.

Version History

Introduced before R2006a