Access Keys:
Skip to content (Access Key - 0)

How can I plot data points from a file?

Matlab is actually quite useful even for things as simple as plotting a file of data points. First you'll need a file with all the proper values. Let's say you have a file with all your data, arranged like this:

        x1 y1
        x2 y2
        x3 y3
        .. ..
        xn yn

Let's additionally say that the name of the file is "test.dat". To load the data into matlab you would type the following at the matlab prompt:

        load test.dat

Then "test" becomes a matrix where the first column is X and the second column is Y. To plot this, you can type:

        plot( test(:,1), test(:,2) )

Where "test(:,1)" means "the entire first column of matrix test".

IS&T Contributions

Documentation and information provided by IS&T staff members

Last Modified:

February 18, 2009

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
olc-matlab olc-matlab Delete
matlab matlab Delete
plot plot Delete
matlab-review matlab-review Delete
sam-duplicate sam-duplicate Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
This product/service is:
Easy to use
Difficult to use

This article is:
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki