linkdata
Automatically update charted data
Description
Use data linking to synchronize charts and their workspace variables. Linked charts automatically update with changes to workspace variables, and workspace variables automatically update with chart modifications made via the brush tool.
Link charts and workspace variables using thelinkdata
function or by selectingfrom the figure toolbar.
Creation
Syntax
Description
linkdata on
turns on data linking mode for the current axes.
linkdata off
turns off data linking mode.
linkdata
toggles the data linking mode between'on'
and'off'
.
linkdata showdialog
opens theLinked Plot Data Sourcesdialog box. Use this syntax to interactively synchronize a chart with workspace variables.
linkdata(
specifies the data linking mode for the specified figure. Use single or double quotation marks around the optionsfig
,___)'on'
and'off'
. For example,linkdata(fig,'on')
.
l = linkdata
creates aLinkData
object. This syntax is useful for querying the data linking mode.
l = linkdata(
creates afig
)LinkData
object for the specified figure.
Input Arguments
Properties
Examples
Tips
If
linkdata
cannot unambiguously identify data sources for a chart, then the chart will not synchronize with workspace variables. If you calllinkdata
and your chart does not update when you change a variable, then open theLinked Plot Data Sourcesdialog box by callinglinkdata showdialog
and manually link the chart to its data sources.The
linkdata
function updates linked data sources and charts around twice a second. To smoothly animate changes in data values, create loops that execute two times per second or less. For more information, see thepause
function.Once a chart is synchronized with its workspace variables, programmatic changes to the data properties of the chart (for example,
XData
) do not update the workspace variables. Workspace variables only update when you modify plotted data interactively, using the brush tool.
Algorithms
数据连接连接图表和工作区riables using the chart's data source properties (for example,XDataSource
). When you turn on data linking for a figure, MATLAB®compares variables in the workspace to plotted data in the figure. When it finds a match, MATLAB assigns that variable to the appropriate data source property of the chart.