Access Keys:
Skip to content (Access Key - 0)
 
More about this article
Created: 11/07/2008 10:33
Modified: 02/18/2009 01:30

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".

Your Rating: Results: PatheticBadOKGoodOutstanding! 2 rates

Adaptavist Theme Builder Powered by Atlassian Confluence