Getting Started |
Modifying the Graph Data Source
You can link graph data to variables in your workspace. When you change the values contained in the variables, you can then update the graph to use the new data without having to create a new graph. (See also the refresh
function.)
Suppose you have the following data:
Using the plotting tools, create a graph of y = sin(x):
New Values for the Data Source
The data that defines the graph is linked to the x
and y
variables in the base workspace. If you assign new values to these variables and click the Refresh Data button, MATLAB updates the graph to use the new data:
x = linspace(-2*pi,2*pi,25);% 25 points between -2pi
and 2
pi y = sin(x);% Recalculate y based on the new x values
Examples -- Using MATLAB Plotting Tools | Preparing Graphs for Presentation |
© 1994-2005 The MathWorks, Inc.