1
votes

Now I get a matrix named Test with 1000 rows and 2 columns, which contains the (x, y) coordinates of 1000 dots. The first column is the values of X-coordinate, and the second is the values of Y-coordinate.

Now I want to display(plot) all the dots, but I found it's wrong if I just used plot(Test).

Could you guys give me a solution?

2

2 Answers

1
votes

When you use the single-argument form of plot (i.e. plot(Y)), when Y is a matrix each column of Y is plotted against the row number.

If column 1 represents x and column 2 is y you need to use the two-argument form:

plot(Test(:,1), Test(:,2))
1
votes

It sounds like you want a scatter plot, which you can get by,

plot(Test(:,1), Test(:,2), '*')

You can change the marker to a number of different symbols. For example, 'o' gives a circle, '*' gives an asterisk, '.' gives a point, etc. See the documents for plot for the full list.

If you leave off the marker specification, it will default to no marker with a solid line connecting the points -- not good for a scatter plot!