| MATLAB® | ![]() |
| On this page… |
|---|
After you import data into the MATLAB® workspace, it is a good idea to plot the data so that you can explore its features. An exploratory plot of your data enables you to identify discontinuities and potential outliers, as well as the regions of interest.
The Plots and Plotting Tools section of the MATLAB Graphics documentation fully describes the MATLAB figure window, which displays the plot, and the types of graphs you can create in figure windows. It also discusses the various interactive tools available for editing and customizingMATLAB graphics.
If you are working with time series data, see Time Series Tools for detailed information about working with time series plots.
In this example, you perform the following tasks on the data in a space-delimited text file:
This example uses sample data in count.dat that consists of three sets of hourly traffic counts, recorded at three different town intersections over a 24-hour period. Each data column in the file represents data for one intersection.
Import data into the workspace using the load function:
load count.dat
Loading this data creates a 24-by-3 matrix called count in the MATLAB workspace.
You can get the size of the data matrix by
[n,p] = size(count)
n =
24
p =
3
where n represents the number of rows, and p represents the number of columns.
Create a time vector, t, containing integers from 1 to n:
t = 1:n;
Use the following commands to plot the data as a function of time, and to annotate the plot:
plot(t,count),
legend('Location 1','Location 2','Location 3',2)
xlabel('Time'), ylabel('Vehicle Count')
Traffic Counts at Three Intersections

![]() | Importing and Exporting Data | Missing Data | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |